/** * 分享到QQ * * @param context * @param title 标题 * @param content 内容 * @param imageUrl 图片的url * @param TargetUrl 点击跳转的url */ public void shareQQ( Activity activity, String title, String content, String imageUrl, String targetUrl) { UMQQSsoHandler qqSsoHandler = new UMQQSsoHandler(activity, "1105114003", "KLbzI6NDcNbSZHwg"); qqSsoHandler.addToSocialSDK(); // 首先在您的Activity中添加如下成员变量 final UMSocialService mController = UMServiceFactory.getUMSocialService("com.umeng.share"); // 设置微信朋友圈分享内容 QQShareContent qqShareContent = new QQShareContent(); qqShareContent.setShareContent(content); // 设置朋友圈title qqShareContent.setTitle(title); // //设置分享图片 qqShareContent.setShareImage(new UMImage(activity, imageUrl)); qqShareContent.setTargetUrl(targetUrl); mController.setShareMedia(qqShareContent); mController.postShare( activity, SHARE_MEDIA.QQ, new SnsPostListener() { @Override public void onStart() {} @Override public void onComplete(SHARE_MEDIA arg0, int eCode, SocializeEntity arg2) { if (eCode == 200) { } else { String eMsg = ""; if (eCode == -101) { eMsg = "没有授权"; } Log.d("TAG", "分享失败[" + eCode + "] " + eMsg); } } }); }
public static void uMengShare( Activity context, String title, String content, int resId, String imageUrl, Bitmap bitmap) { UMSocialService controlService = UMServiceFactory.getUMSocialService(ConstantS.ID.DESCRIPTOR); controlService.getConfig().setSsoHandler(new SinaSsoHandler()); controlService.getConfig().setSsoHandler(new TencentWBSsoHandler()); UMQQSsoHandler qqSsoHandler = new UMQQSsoHandler( context, ConstantS.AppId.TENCENT_APP_ID, ConstantS.AppId.TENCENT_APP_SECRET); qqSsoHandler.setTargetUrl(context.getString(R.string.share_url)); qqSsoHandler.addToSocialSDK(); SmsHandler smsHandler = new SmsHandler(); smsHandler.addToSocialSDK(); // 添加QZone平台 QZoneSsoHandler qZoneSsoHandler = new QZoneSsoHandler( context, ConstantS.AppId.TENCENT_APP_ID, ConstantS.AppId.TENCENT_APP_SECRET); qZoneSsoHandler.addToSocialSDK(); UMWXHandler wxHandler = new UMWXHandler(context, ConstantS.AppId.WX_APP_ID, ConstantS.AppId.WX_APP_SECRET); wxHandler.addToSocialSDK(); UMWXHandler wxCircleHandler = new UMWXHandler(context, ConstantS.AppId.WX_APP_ID, ConstantS.AppId.WX_APP_SECRET); wxCircleHandler.setToCircle(true); wxCircleHandler.addToSocialSDK(); UMImage umImage = null; if (resId != 0) { umImage = new UMImage(context, resId); } if (!TextUtils.isEmpty(imageUrl)) { umImage = new UMImage(context, imageUrl); } if (bitmap != null) { umImage = new UMImage(context, bitmap); } SmsShareContent smsShareContent = new SmsShareContent(); smsShareContent.setShareContent(content); smsShareContent.setShareImage(umImage); TencentWbShareContent tencent = new TencentWbShareContent(); tencent.setShareContent(content); tencent.setTargetUrl(context.getString(R.string.share_url)); tencent.setShareImage(umImage); QQShareContent qqShareContent = new QQShareContent(); qqShareContent.setShareContent(content); qqShareContent.setTitle(title); qqShareContent.setTargetUrl(context.getString(R.string.share_url)); qqShareContent.setShareImage(umImage); QZoneShareContent qZoneShareContent = new QZoneShareContent(); qZoneShareContent.setShareContent(content); qZoneShareContent.setTitle(title); qZoneShareContent.setTargetUrl(context.getString(R.string.share_url)); qZoneShareContent.setShareImage(umImage); WeiXinShareContent weiXinShareContent = new WeiXinShareContent(); weiXinShareContent.setShareContent(content); weiXinShareContent.setTitle(title); weiXinShareContent.setTargetUrl(context.getString(R.string.share_url)); weiXinShareContent.setShareImage(umImage); CircleShareContent circleShareContent = new CircleShareContent(); circleShareContent.setShareContent(content); circleShareContent.setTitle(title); circleShareContent.setTargetUrl(context.getString(R.string.share_url)); circleShareContent.setShareImage(umImage); SinaShareContent sinaShareContent = new SinaShareContent(); sinaShareContent.setShareContent(content); sinaShareContent.setShareImage(umImage); sinaShareContent.setTargetUrl(context.getString(R.string.share_url)); sinaShareContent.setTitle(title); controlService.setShareMedia(sinaShareContent); controlService.setShareMedia(weiXinShareContent); controlService.setShareMedia(circleShareContent); controlService.setShareMedia(tencent); controlService.setShareMedia(qqShareContent); controlService.setShareMedia(qZoneShareContent); controlService.setShareMedia(smsShareContent); controlService.openShare(context, false); }