Use SHARESDK for sharing in Android

Source: Internet
Author: User

1, on the Http://www.mob.com official website to create a background application (if no account of the students to register first), the main post is the Appkey value of your newly created application

2, here we share Sina Weibo as an example, in the Sina Weibo SDK to create a new application, mainly to get the Appkey and Appsecret value of this application

3, download the SDK client, extract it out, in SHARESDK for Android folder run Quickintegrater.jar This file (provided that your PC is near the JDK installed and configured with the environment variables, run with Javaw.exe), create our integration reference (here we only select Sina Weibo), and import it into our project

4, configuration Androidmanifest.xml

A: Add 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 "/> <!--bluetooth sharing required Permissions--  <uses-permission android:name=" Android.permission.BLUETOOTH "/>  <uses-permission android:name= "Android.permission.BLUETOOTH_ADMIN"/>

B: Add activity Information

<activity android:name= "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>

5 . Add basic sharing information to the main activity

protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);//2, Initialize SHARESDKSHARESDK.INITSDK (Getapplicationcontext ()); Setcontentview (r.layout.activity_main); btn_main_share = ( Button) Findviewbyid (r.id.btn_main_share),//3, add permission and the Activitybtn_main_share.setonclicklistener we want to use (new Onclicklistener () {//1, set share basic information public void OnClick (View v) {//Create one-click Share object Onekeyshare onekeyshare = new Onekeyshare ();// Set the title Onekeyshare.settitle ("Mu class network Sharing");//Set Up information Onekeyshare.settext ("I use technology for MU class network endorsement");//Set Icon Onekeyshare.setimageurl ("http ://img.taopic.com/uploads/allimg/130501/240451-13050106450911.jpg ");//Display share list onekeyshare.show (MainActivity.this );}});}

6, replace the Sharesdk.xml file in the project's asset file with the Appkey of the mob background application and the key of each platform application

Now we can implement our sharing function, note: If the use of sharesdk to Sina Weibo "21322:redirect_uri_mismathch (C400)", it indicates that your Sina licensing problems, We need to check the two attributes in our Sharesdk.xml file, and these two properties are fixed and must be changed.

Redirecturl= "http://www.sharesdk.cn"        sharebyappclient= "true"

  

 

  

Use SHARESDK for sharing in Android

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.