Android Studio Simple integrated mob sharing plugin

Source: Internet
Author: User

First, create the app on the service platform Second, download the SDK, add the library file

Third, add the required permissions

<uses-permission android:name= "Android.permission.GET_TASKS"/>
<uses-permission android:name= "Android.permission.INTERNET"/>
<uses-permission android:name= "Android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name= "Android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name= "Android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>
<uses-permission android:name= "Android.permission.MANAGE_ACCOUNTS"/>
<uses-permission android:name= "Android.permission.GET_ACCOUNTS"/>
<!--the required permissions for Bluetooth sharing--
<uses-permission android:name= "Android.permission.BLUETOOTH"/>
<uses-permission android:name= "Android.permission.BLUETOOTH_ADMIN"/>

Iv. Adding related activity

<activity
Android:name= "cn.sharesdk.framework. Sharesdkuishell"//The file may change with version 2.6 is Com.mob.tools.MobUIShell

Android:theme= "@android: Style/theme.translucent.notitlebar"
Android:configchanges= "Keyboardhidden|orientation|screensize"
android:screenorientation= "Portrait"
Android:windowsoftinputmode= "Statehidden|adjustresize" >
<intent-filter>
<data android:scheme= "tencent100371282"/>
<action android:name= "Android.intent.action.VIEW"/>
<category android:name= "Android.intent.category.BROWSABLE"/>
<category android:name= "Android.intent.category.DEFAULT"/>
</intent-filter>
</activity>

===========, easy letter required ===================

<!--share Callback--
<activity
Android:name= ". Wxapi. Wxentryactivity "
Android:theme= "@android: Style/theme.translucent.notitlebar"
Android:configchanges= "Keyboardhidden|orientation|screensize"
Android:exported= "true"
android:screenorientation= "Portrait"/>

<!--easy-to-trust share callback--
<activity
Android:name= ". Yxapi. Yxentryactivity "
Android:theme= "@android: Style/theme.translucent.notitlebar"
Android:configchanges= "Keyboardhidden|orientation|screensize"
Android:exported= "true"
android:screenorientation= "Portrait"/>

V. Add your Appkey (Mob official map source)

Vi. Calling Share code

private void Showshare () {
SHARESDK.INITSDK (this);
Onekeyshare OKs = new Onekeyshare ();
Turn off SSO Licensing
Oks.disablessowhenauthorize ();

This method is not called when sharing notification icons and text 2.5.9 later versions
Oks.setnotification (R.drawable.ic_launcher, getString (r.string.app_name));
Title, Evernote, email, information, Renren and QQ space use
Oks.settitle (getString (R.string.share));
Titleurl is the title of the network link, only in Renren and QQ space use
Oks.settitleurl ("http://sharesdk.cn");
Text is shared, and all platforms require this field
Oks.settext ("I am sharing text");
ImagePath is the local path to the picture, and this parameter is supported on platforms other than linked-in
Oks.setimagepath ("/sdcard/test.jpg");//Ensure that this picture exists sdcard
URLs are only used in (including friends and friends circles)
Oks.seturl ("http://sharesdk.cn");
Comment is my comment on this share, only used in Renren and QQ space
Oks.setcomment ("I am the test Review text");
Site is the name of the website that shares this content and is used only in QQ space
Oks.setsite (getString (r.string.app_name));
SiteURL is the address of the website sharing this content, only in the QQ space use
Oks.setsiteurl ("http://sharesdk.cn");

Start sharing GUI
Oks.show (this);
}

Other precautions:

1, possibly due to the version of Android studio, SHARESDK storage location will affect the final effect, such as:

Only the Sharesdk.xml folder appears this flag to represent the file is referenced, and the official demo is Eclipes version, not stored in the main directory, note

Android Studio Simple integrated mob sharing plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.