Android應用程序想使用微信、微信朋友圈、QQ或者QQ空間分享都比較常見,可是配置很是繁瑣,就算是使用友盟也同樣。
java
申請地址:https://open.weixin.qq.comandroid
須要的基本信息:包名+MD5簽名微信
得到AppID以供使用。吐槽一下,這裏的應用簽名是指MD5簽名,那特麼的卻是寫清楚啊,QQ和百度地圖是要求SHA1簽名,QQ和新浪微博要求的是MD5簽名,這可真是無聊。app
申請地址:http://connect.qq.com/ide
須要的基本信息:包名+sha1簽名post
得到APP ID以及APP KEY以供使用。這裏不得不吐槽一下,申請QQ認證的時候,apk的下載地址是必須填寫的,可是尚未完成QQ分享集成的話,應用如何提交應用市場?反過來,不提交應用市場如何得到下載地址?因此,這就是個逗比。網站
申請地址:http://open.weibo.com/spa
須要的基本信息:包名+MD5簽名code
得到APP ID以及App Secret以供使用。吐槽:呵呵orm
社會化分享-》設置-》自定義配置
<activity android:name="com.tencent.tauth.AuthActivity" android:launchMode="singleTask" android:noHistory="true" > <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <!-- xxxxxx,若是你使用的公用帳號,則不須要修改;不然修改爲你在QQ開放平臺申請的 APP ID --> <data android:scheme="tencent剛剛得到的QQ appId" /> </intent-filter> </activity>
MSocialService mUMSocialService = UMServiceFactory.getUMSocialService("com.umeng.share", RequestType.SOCIAL); mUMSocialService.getConfig().supportWXPlatform(act, weixinAppId, contentUrl); WeiXinShareContent media = new WeiXinShareContent(new UMImage(getActivity(), drawableId)); media.setTitle(titleString); media.setShareContent(contentString); media.setTargetUrl(targetUrl); mUMSocialService.setShareMedia(media); mUMSocialService.postShare(getSelfContext(), SHARE_MEDIA.WEIXIN, new SnsPostListener() { @Override public void onStart() { } @Override public void onComplete(SHARE_MEDIA platform, int eCode, SocializeEntity entity) { } });
UMSocialService mUMSocialService = UMServiceFactory.getUMSocialService("com.umeng.share", RequestType.SOCIAL); mUMSocialService.getConfig().supportWXPlatform(act, weixinAppId, contentUrl); mUMSocialService.getConfig().supportWXCirclePlatform(act, weixinAppId, contentUrl); CircleShareContent media = new CircleShareContent(new UMImage(getActivity(), drawableId)); media.setTitle(titleString); media.setShareContent(contentString); media.setTargetUrl(targetUrl); mUMSocialService.setShareMedia(media); mUMSocialService.postShare(getSelfContext(), SHARE_MEDIA.WEIXIN_CIRCLE, new SnsPostListener() { @Override public void onStart() { } @Override public void onComplete(SHARE_MEDIA platform, int eCode, SocializeEntity entity) { } });
UMSocialService mUMSocialService = UMServiceFactory.getUMSocialService("com.umeng.share", RequestType.SOCIAL); mUMSocialService.getConfig().supportQQPlatform(act, QQAppId, QQAppKey, contentUrl); QQShareContent qqShareContent = new QQShareContent(); qqShareContent.setShareContent(contentString); qqShareContent.setTitle(titleString); qqShareContent.setTargetUrl(targetUrl); mUMSocialService.setShareMedia(qqShareContent); mUMSocialService.postShare(getSelfContext(), SHARE_MEDIA.QQ, new SnsPostListener() { @Override public void onStart() { } @Override public void onComplete(SHARE_MEDIA platform, int eCode, SocializeEntity entity) { } });
UMSocialService mUMSocialService = UMServiceFactory.getUMSocialService("com.umeng.share", RequestType.SOCIAL); mUMSocialService.getConfig().supportQQPlatform(act, QQAppId, QQAppKey, contentUrl); QZoneShareContent qZoneShareContent = new QZoneShareContent(); qZoneShareContent.setShareContent(contentString); qZoneShareContent.setTitle(titleString); qZoneShareContent.setTargetUrl(targetUrl); mUMSocialService.setShareMedia(qZoneShareContent); mUMSocialService.postShare(getSelfContext(), SHARE_MEDIA.QZONE, new SnsPostListener() { @Override public void onStart() { } @Override public void onComplete(SHARE_MEDIA platform, int eCode, SocializeEntity entity) { } });
UMSocialService mUMSocialService = UMServiceFactory.getUMSocialService("com.umeng.share", RequestType.SOCIAL); mUMSocialService.setShareContent(contentString); mUMSocialService.postShare(getSelfContext(), SHARE_MEDIA.SINA, new SnsPostListener() { @Override public void onStart() { } @Override public void onComplete(SHARE_MEDIA platform, int eCode, SocializeEntity entity) { } });
主要是代碼設置支持平臺的代碼有改變,好比:
// 添加微信平臺 UMWXHandler wxHandler = new UMWXHandler(getActivity(),appId,appSecret); wxHandler.addToSocialSDK(); // 添加微信朋友圈 UMWXHandler wxCircleHandler = new UMWXHandler(getActivity(),appId,appSecret); wxCircleHandler.setToCircle(true); wxCircleHandler.addToSocialSDK();
其餘能夠參照具體文檔
Android分享 Q羣:315658668