友盟第三方 社会化分享
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了友盟第三方 社会化分享相关的知识,希望对你有一定的参考价值。
1 2 3 4 <!-- APPkey值 --> 5 <meta-data android:name="UMENG_APPKEY" android:value="56e8befae0f55aeb1e0010a9"/> 6 <activity android:configChanges="orientation|keyboard" android:launchMode="singleTask" android:name="com.umeng.socialize.view.ShareActivity" android:noHistory="true" android:theme="@style/Theme.UMDialog" android:windowSoftInputMode="stateVisible|adjustResize"/> 7 <activity android:configChanges="keyboardHidden|orientation|screenSize" android:exported="true" android:name=".wxapi.WXEntryActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent.NoTitleBar"/> 8 9 10 <!-- ############ QQ空间和QQ SSO授权的Activity注册 ############ --> 11 <activity 12 android:name="com.tencent.tauth.AuthActivity" 13 android:launchMode="singleTask" 14 android:noHistory="true" > 15 <intent-filter> 16 17 <action android:name="android.intent.action.VIEW" /> 18 <category android:name="android.intent.category.DEFAULT" /> 19 <category android:name="android.intent.category.BROWSABLE" /> 20 <data android:scheme="tencent你的QQ互联APPID" /> 21 </intent-filter> 22 </activity> 23 <activity android:name="com.tencent.connect.common.AssistActivity" 24 android:theme="@android:style/Theme.Translucent.NoTitleBar" 25 android:screenOrientation="portrait"> 26 </activity> 27 </application> 28 29 30 31 32 <!-- QQ的权限 --> 33 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 34 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> 35 <uses-permission android:name="android.permission.READ_PHONE_STATE"/> 36 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 37 <uses-permission android:name="android.permission.INTERNET"/> 38 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 39 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 40 </manifest>
1 import com.umeng.socialize.controller.UMServiceFactory; 2 import com.umeng.socialize.controller.UMSocialService; 3 import com.umeng.socialize.media.UMImage; 4 import com.umeng.socialize.sso.QZoneSsoHandler; 5 import com.umeng.socialize.sso.UMQQSsoHandler; 6 7 import android.support.v7.app.ActionBarActivity; 8 import android.content.Context; 9 import android.os.Bundle; 10 import android.view.Menu; 11 import android.view.MenuItem; 12 import android.view.View; 13 import android.view.View.OnClickListener; 14 import android.widget.Button; 15 16 public class MainActivity extends ActionBarActivity { 17 private Button bt; 18 Context mContext; 19 UMSocialService mControllerShare; 20 String imgurl = "http://img.firefoxchina.cn/2016/03/8/201603300937230.jpg"; 21 @Override 22 protected void onCreate(Bundle savedInstanceState) { 23 super.onCreate(savedInstanceState); 24 setContentView(R.layout.activity_main); 25 26 mControllerShare = UMServiceFactory.getUMSocialService("com.umeng.share"); 27 28 init(); 29 } 30 private void init() { 31 // TODO Auto-generated method stub 32 // 设置分享内容 33 34 bt = (Button)findViewById(R.id.button1); 35 36 mControllerShare.setShareContent("!!!!!!!!"); 37 // 设置分享图片, 参数2为图片的url地址 38 // mControllerShare.getConfig().removePlatform( SHARE_MEDIA.RENREN, SHARE_MEDIA.DOUBAN); 39 bt.setOnClickListener(new OnClickListener() { 40 @Override 41 public void onClick(View v) { 42 mControllerShare.setShareMedia(new UMImage(mContext, imgurl)); 43 // 是否只有已登录用户才能打开分享选择页 44 mControllerShare.openShare(MainActivity.this, false); 45 } 46 }); 47 //参数1为当前Activity, 参数2为开发者在QQ互联申请的APP ID,参数3为开发者在QQ互联申请的APP kEY. 48 UMQQSsoHandler qqSsoHandler = new UMQQSsoHandler(this, "100424468", 49 "c7394704798a158208a74ab60104f0ba"); 50 qqSsoHandler.addToSocialSDK(); 51 52 //参数1为当前Activity, 参数2为开发者在QQ互联申请的APP ID,参数3为开发者在QQ互联申请的APP kEY. 53 QZoneSsoHandler qZoneSsoHandler = new QZoneSsoHandler(this, "100424468", 54 "c7394704798a158208a74ab60104f0ba"); 55 qZoneSsoHandler.addToSocialSDK(); 56 57 } 58 }
以上是关于友盟第三方 社会化分享的主要内容,如果未能解决你的问题,请参考以下文章