友盟5.0分享 总结

        本文章仅是做分享过程中遇到的问题解决方法的记录,以免自己以后遇到类似问题难以解决。

首先分享,根据http://dev.umeng.com/social/android/android-update#8中的集成文档 把该有的配置都加上。

注意新浪微博的应用未审核成功的话 需要在开放者平台增加测试号,各个平台应用信息要补全。

注意的是qq好友分享在AndroidManifest.xml中的配置

 <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" />


                <data android:scheme="tencent+AppId" />//这一步如果写错会导致qq分享成功后回调 onCancel() 并不是正常的onResult();
            </intent-filter>
        </activity>
        <activity
            android:name="com.tencent.connect.common.AssistActivity"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />



表格表示qq好友分享http开头的点击后是默认网址。

新浪分享:分享失败 1.到http://open.weibo.com/网站中晚上应用信息,必填的一定要填完

                                      2.本地代码中需要在packageName下加入WBShareActivity这个类 Demo中有体现。

腾讯微博:未分享成功未跳web页,直接回调onResult()方法,是未授权导致的,需要加入授权方法。未审核成功的应用是无法进行腾讯微博分享的

//点击友盟分享图标的监听

private ShareBoardlistener shareBoardlistener = new ShareBoardlistener() {
@Override
public void onclick(SnsPlatform snsPlatform, SHARE_MEDIA share_media) {
if (share_media.equals(SHARE_MEDIA.TENCENT)) {
mShareAPI.doOauthVerify(AboutActivity.this, share_media,
umAuthListener);
} else if (share_media.equals(SHARE_MEDIA.SINA)) {
new ShareAction(AboutActivity.this)
.setPlatform(share_media)
.setCallback(umShareListener)
.withText(
getString(R.string.share_content)
+ download_url).withMedia(image)
.share();//增加图片和内容在这里做,否則分享不成功。//新浪分享在文字後面加String類型的 url,用withTargetUrl并且图片是url分享不成功且显示不正确。用withTargetUrl且图片不是url 分享成功但显示不正确 文字后面会显示分享视频的字样。所以建议url写在文本后面,这样图片是url既可以分享成功又不会显示出错。
} else {
new ShareAction(AboutActivity.this).setPlatform(share_media)
.setCallback(umShareListener)
.withText(getString(R.string.share_content))
.withMedia(image).withTargetUrl(download_url).share();//增加图片和内容在这里做,否則分享不成功。
}
}
};
/** auth callback interface **/
private UMAuthListener umAuthListener = new UMAuthListener() {
@Override
public void onComplete(SHARE_MEDIA platform, int action,
Map<String, String> data) {
// Toast.makeText(getApplicationContext(), "Authorize succeed",
// Toast.LENGTH_SHORT).show();
new ShareAction(AboutActivity.this)
.setPlatform(SHARE_MEDIA.TENCENT)
.setCallback(umShareListener)
.withText(getString(R.string.share_content) + download_url)
.withMedia(image).share();//授权成功后分享,腾讯微博的条目不能点击 所以只能在文本后面添加url 点击url才能跳转网页
}


@Override
public void onError(SHARE_MEDIA platform, int action, Throwable t) {
Toast.makeText(getApplicationContext(), "Authorize fail",
Toast.LENGTH_SHORT).show();
}


@Override
public void onCancel(SHARE_MEDIA platform, int action) {
Toast.makeText(getApplicationContext(), "Authorize cancel",
Toast.LENGTH_SHORT).show();
}
};


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
/** attention to this below ,must add this **/
mShareAPI.onActivityResult(requestCode, resultCode, data);


}


微信分享:包名下 wxapi--WXEntryActivity.java 自不必多說。

这三个分享成功还需要一个必要条件就是 打签名包。 


猜你喜欢

转载自blog.csdn.net/u010351988/article/details/50622743
今日推荐