新版友盟umeng.com集成分享和登录的说明
原来的AndroidManifest.xml中的配置不变
在Application的oncreate方法中添加各个平台的配置
PlatformConfig.setWeixin(Constants.weixinAppID, Constants.weixinAppSecret);//微信 appid appsecret
PlatformConfig.setQQZone(Constants.qqAppID, Constants.qqAppSecret); // QQ和Qzone appid appkey
分享
new ShareAction(this).setPlatform(SHARE_MEDIA.QQ).setCallback(umShareListener)
.withText(“hello umeng video”)
.withTargetUrl(“http://www.baidu.com”)
.withMedia(image)
.share();
UMImage image = new UMImage(ShareActivity.this, “http://www.umeng.com/images/pic/social/integrated_3.png”);//图片文件
private UMShareListener umShareListener = new UMShareListener() {
@Override
public void onResult(SHARE_MEDIA platform) {
Toast.makeText(ShareActivity.this, platform + ” 分享成功啦”, Toast.LENGTH_SHORT).show();
}
@Override
public void onError(SHARE_MEDIA platform, Throwable t) {
Toast.makeText(ShareActivity.this,platform + ” 分享失败啦”, Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel(SHARE_MEDIA platform) {
Toast.makeText(ShareActivity.this,platform + ” 分享取消了”, Toast.LENGTH_SHORT).show();
}
};
近期评论