Search in sources :

Example 1 with UMShareListener

use of com.umeng.socialize.UMShareListener in project AnkiChinaAndroid by ankichinateam.

the class WebViewActivity method shareUrl.

public void shareUrl(String url, String title, String desc, String thumb, SHARE_MEDIA share_media) {
    UMWeb web = new UMWeb(url);
    web.setTitle(title);
    web.setThumb(new UMImage(this, thumb));
    web.setDescription(desc);
    new ShareAction(this).withMedia(web).setPlatform(share_media).setCallback(new UMShareListener() {

        @Override
        public void onStart(SHARE_MEDIA share_media) {
        }

        @Override
        public void onResult(SHARE_MEDIA share_media) {
        }

        @Override
        public void onError(SHARE_MEDIA share_media, Throwable throwable) {
        }

        @Override
        public void onCancel(SHARE_MEDIA share_media) {
        }
    }).share();
}
Also used : UMShareListener(com.umeng.socialize.UMShareListener) SHARE_MEDIA(com.umeng.socialize.bean.SHARE_MEDIA) ShareAction(com.umeng.socialize.ShareAction) UMImage(com.umeng.socialize.media.UMImage) UMWeb(com.umeng.socialize.media.UMWeb)

Example 2 with UMShareListener

use of com.umeng.socialize.UMShareListener in project SmartCampus by Vegen.

the class ShareUtils method shareWeb.

/**
 * 分享链接
 */
public static void shareWeb(final Activity activity, String WebUrl, String title, String description, String imageUrl, int imageID) {
    // 连接地址
    UMWeb web = new UMWeb(WebUrl);
    // 标题
    web.setTitle(title);
    // 描述
    web.setDescription(description);
    if (TextUtils.isEmpty(imageUrl)) {
        // 本地缩略图
        web.setThumb(new UMImage(activity, imageID));
    } else {
        // 网络缩略图
        web.setThumb(new UMImage(activity, imageUrl));
    }
    new ShareAction(activity).setDisplayList(SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE, SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.WEIXIN_FAVORITE, SHARE_MEDIA.SINA).withText(title).withMedia(web).setCallback(new UMShareListener() {

        @Override
        public void onStart(SHARE_MEDIA share_media) {
        }

        @Override
        public void onResult(final SHARE_MEDIA share_media) {
            activity.runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    if (share_media.name().equals("WEIXIN_FAVORITE")) {
                        Toast.makeText(activity, share_media + " 收藏成功", Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(activity, share_media + " 分享成功", Toast.LENGTH_SHORT).show();
                    }
                }
            });
        }

        @Override
        public void onError(final SHARE_MEDIA share_media, final Throwable throwable) {
            if (throwable != null) {
                Log.d("throw", "throw:" + throwable.getMessage());
            }
            activity.runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    Toast.makeText(activity, share_media + " 分享失败", Toast.LENGTH_SHORT).show();
                }
            });
        }

        @Override
        public void onCancel(final SHARE_MEDIA share_media) {
            activity.runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    Toast.makeText(activity, share_media + " 分享取消", Toast.LENGTH_SHORT).show();
                }
            });
        }
    }).open();
}
Also used : UMShareListener(com.umeng.socialize.UMShareListener) SHARE_MEDIA(com.umeng.socialize.bean.SHARE_MEDIA) ShareAction(com.umeng.socialize.ShareAction) UMImage(com.umeng.socialize.media.UMImage) UMWeb(com.umeng.socialize.media.UMWeb)

Example 3 with UMShareListener

use of com.umeng.socialize.UMShareListener in project AnkiChinaAndroid by ankichinateam.

the class PosterActivity method shareUrl.

public void shareUrl(View view, SHARE_MEDIA share_media) {
    Bitmap bitmap = createBitmapFromView(view);
    UMImage imagelocal = new UMImage(this, bitmap);
    imagelocal.setThumb(new UMImage(this, bitmap));
    new ShareAction(this).withMedia(imagelocal).setPlatform(share_media).setCallback(new UMShareListener() {

        @Override
        public void onStart(SHARE_MEDIA share_media) {
        }

        @Override
        public void onResult(SHARE_MEDIA share_media) {
        }

        @Override
        public void onError(SHARE_MEDIA share_media, Throwable throwable) {
        }

        @Override
        public void onCancel(SHARE_MEDIA share_media) {
        }
    }).share();
}
Also used : Bitmap(android.graphics.Bitmap) UMShareListener(com.umeng.socialize.UMShareListener) SHARE_MEDIA(com.umeng.socialize.bean.SHARE_MEDIA) ShareAction(com.umeng.socialize.ShareAction) UMImage(com.umeng.socialize.media.UMImage)

Aggregations

ShareAction (com.umeng.socialize.ShareAction)3 UMShareListener (com.umeng.socialize.UMShareListener)3 SHARE_MEDIA (com.umeng.socialize.bean.SHARE_MEDIA)3 UMImage (com.umeng.socialize.media.UMImage)3 UMWeb (com.umeng.socialize.media.UMWeb)2 Bitmap (android.graphics.Bitmap)1