Beispiel #1
0
  public void shareSMS(
      Activity activity, String title, String content, String imageUrl, String targetUrl) {
    SmsHandler smsHandler = new SmsHandler();
    smsHandler.addToSocialSDK();
    // 首先在您的Activity中添加如下成员变量
    final UMSocialService mController = UMServiceFactory.getUMSocialService("com.umeng.share");
    // 设置微信朋友圈分享内容
    SmsShareContent qqShareContent = new SmsShareContent();
    qqShareContent.setShareContent(title + targetUrl);
    mController.setShareMedia(qqShareContent);

    mController.postShare(
        activity,
        SHARE_MEDIA.SMS,
        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);
            }
          }
        });
  }
Beispiel #2
0
  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);
  }