QQ、Qzone分享的一些注意项

1.

Tencent tencent = Tencent.createInstance("你的appId", mActivity);
Bundle params = new Bundle();
params.putString(QzoneShare.SHARE_TO_QQ_TARGET_URL, url);
params.putString(QzoneShare.SHARE_TO_QQ_APP_NAME, "我是应用程序名称");
params.putString("title", "我是标题");
params.putString("summary", text);

ArrayList<String> images = new ArrayList<String>();
images.add(thumbPath);
params.putStringArrayList(QzoneShare.SHARE_TO_QQ_IMAGE_URL, images);
tencent.shareToQzone(mActivity, params, new IUiListener());
// 刚开始点击分享老是没反应,后来才发现Qzone分享必须设置缩略图才行

2.

Tencent tencent = Tencent.createInstance("appId", mActivity);
Bundle params = new Bundle();
params.putString(QzoneShare.SHARE_TO_QQ_TARGET_URL, url);
params.putString(QzoneShare.SHARE_TO_QQ_APP_NAME, "我是应用程序名称");
params.putString("title", "我是标题");
params.putString("summary", 我是简介);

params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_DEFAULT);
params.putString(QQShare.SHARE_TO_QQ_IMAGE_LOCAL_URL, thumbPath);
tencent.shareToQQ(mActivity, params, new IUiListener());

// 刚开始老是缩略图显示不了,原来QQ分享有本地图片和在线图片之分,一定要只选其一

3.是否出现IUiListener接口中的回调方法没有被调用?

onActivityResult(int requestCode, int resultCode, Intent data) {
//      Tencent.onActivityResultData(requestCode, resultCode, data, mUiListener);
        if(requestCode == Constants.REQUEST_QQ_SHARE || requestCode == Constants.REQUEST_QZONE_SHARE){
            if (resultCode == Constants.ACTIVITY_OK) {
                Tencent.handleResultData(data, mUiListener);
            }
        }
    }
// 刚开始发现,onComplete、onCancell、onError这三个方法没一个被调用了,也就导致没有办法统计分享成功比率
// 微博分享就不需要在onActivity中去触发WeiboAuthListener的方法调用

转载:http://www.oschina.net/code/snippet_266004_50547

你可能感兴趣的:(Android)