com.tencent.mm.sdk.modelmsg.WXWebpageObject Java Examples
The following examples show how to use
com.tencent.mm.sdk.modelmsg.WXWebpageObject.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShareByWeixin.java From ShareSDK with MIT License | 6 votes |
/** * 构建WXMediaMessage * * @param bitmap */ private WXMediaMessage buildWXMediaMessage(Bitmap bitmap) { WXMediaMessage wxMediaMessage = new WXMediaMessage(); wxMediaMessage.title = data.getTitle(); wxMediaMessage.description = data.getContent(); if (TextUtils.isEmpty(data.getUrl())) { wxMediaMessage.mediaObject = new WXTextObject(data.getContent()); } else { if (null != bitmap) { wxMediaMessage.setThumbImage(getWxShareBitmap(bitmap)); } else { Bitmap defautlBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.share_default); if (null != defautlBitmap) { wxMediaMessage.setThumbImage(getWxShareBitmap(defautlBitmap)); } } wxMediaMessage.mediaObject = new WXWebpageObject(data.getUrl()); } return wxMediaMessage; }
Example #2
Source File: WeixinHelper.java From android-common-utils with Apache License 2.0 | 6 votes |
public void shareWebUrlWithIcon(Bitmap icon, String shareUrl, String title, String desc, boolean shareToFriendCircle, IWXShareCallback callback) { final String id = buildTransaction("web_url"); WXWebpageObject webObj = new WXWebpageObject(); webObj.webpageUrl = shareUrl; webObj.extInfo = "this is extInfo"; WXMediaMessage msg = new WXMediaMessage(); msg.mediaObject = webObj; msg.title = title; msg.description = desc; msg.setThumbImage(icon); SendMessageToWX.Req req = new SendMessageToWX.Req(); req.transaction = id; req.message = msg; req.scene = shareToFriendCircle ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; mCallbackMap.put(req.transaction.hashCode(),callback); mWxApi.sendReq(req); }
Example #3
Source File: WeChatShareProxy.java From ESSocialSDK with Apache License 2.0 | 6 votes |
public static void shareToWeChat(final Context context, final String appId, final String title, final String desc, final String url, final String thumbnail, final IWXShareCallback callback) { new Thread(new Runnable() { @Override public void run() { WeChatShareProxy.mCallback = callback; WXWebpageObject webpage = new WXWebpageObject(); webpage.webpageUrl = url; WXMediaMessage msg = new WXMediaMessage(webpage); msg.title = title; msg.description = desc; byte[] thumb = SocialUtils.getHtmlByteArray(thumbnail); if (null != thumb) msg.thumbData = SocialUtils.compressBitmap(thumb, 32); else msg.thumbData = SocialUtils.compressBitmap(SocialUtils.getDefaultShareImage(context), 32); SendMessageToWX.Req req = new SendMessageToWX.Req(); req.transaction = SocialUtils.buildTransaction("webpage"); req.message = msg; req.scene = SendMessageToWX.Req.WXSceneSession; WeChat.getIWXAPIInstance(context, appId).sendReq(req); } }).start(); }
Example #4
Source File: WeChatShareProxy.java From ESSocialSDK with Apache License 2.0 | 6 votes |
public static void shareToWeChatTimeline(final Context context, final String appId, final String title, final String url, final String thumbnail, final IWXShareCallback callback) { new Thread(new Runnable() { @Override public void run() { WeChatShareProxy.mCallback = callback; WXWebpageObject webpage = new WXWebpageObject(); webpage.webpageUrl = url; WXMediaMessage msg = new WXMediaMessage(webpage); msg.title = title; byte[] thumb = SocialUtils.getHtmlByteArray(thumbnail); if (null != thumb) msg.thumbData = SocialUtils.compressBitmap(thumb, 32); else msg.thumbData = SocialUtils.compressBitmap(SocialUtils.getDefaultShareImage(context), 32); SendMessageToWX.Req req = new SendMessageToWX.Req(); req.transaction = SocialUtils.buildTransaction("webpage"); req.message = msg; req.scene = SendMessageToWX.Req.WXSceneTimeline; WeChat.getIWXAPIInstance(context, appId).sendReq(req); } }).start(); }
Example #5
Source File: WeixinShareApi.java From browser with GNU General Public License v2.0 | 5 votes |
private static void doShareWebPage(final String url,final String title,final String desc,final String img,final boolean timelined) { if(api==null) { api= WXAPIFactory.createWXAPI(MainApp.getContext(), APP_ID); } Bitmap bitmap= ImageUtil.getBitmap(img); Bitmap thumb =null; if(bitmap!=null){ thumb=Bitmap.createScaledBitmap(bitmap, 64, 64, true); } WXWebpageObject webpage = new WXWebpageObject(); webpage.webpageUrl = url; WXMediaMessage msg = new WXMediaMessage(webpage); msg.title = title; msg.description = desc; if(thumb!=null) { msg.thumbData = BitmapUtil.bmpToByteArray(thumb, true); }else{ Bitmap thumbIcon = BitmapFactory.decodeResource(MainApp.getInstance().getResources(), R.drawable.icon); msg.thumbData = BitmapUtil.bmpToByteArray(thumbIcon, true); } SendMessageToWX.Req req = new SendMessageToWX.Req(); req.transaction = buildTransaction("webpage"); req.message = msg; req.scene = timelined ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession; api.sendReq(req); }
Example #6
Source File: SharePopWindow.java From QiQuYing with Apache License 2.0 | 5 votes |
/** * 分享到微信朋友或者朋友圈 * @param scene 标记是发送朋友圈还是微信好友 */ private void share2WeiXin(int scene) { if(!api.isWXAppInstalled()) { if(scene == SendMessageToWX.Req.WXSceneSession) { ToastUtils.showMessageInCenter(context, "您没有安装【微信】\n安装后才能分享到微信好友"); } else { ToastUtils.showMessageInCenter(context, "您没有安装【微信】\n安装后才能分享到朋友圈"); } } WXWebpageObject webpage = new WXWebpageObject(); webpage.webpageUrl = targetUrl + mJoke.getId(); WXMediaMessage msg = new WXMediaMessage(webpage); Bitmap thumb = null; switch (mJoke.getType()) { case Joke.TYPE_QUSHI: msg.title = context.getString(R.string.share_title_qushi); msg.description = mJoke.getContent(); thumb = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher); break; case Joke.TYPE_QUTU: msg.title = context.getString(R.string.share_title_qutu); msg.description = mJoke.getTitle(); //微信分享缩略图最大不能超过32K,否则无法调开微信界面 thumb = BitmapUtil.getThumbBitmapFromCache(mJoke.getImgUrl(), 100, 100); break; case Joke.TYPE_MEITU: msg.title = context.getString(R.string.share_title_meitu); msg.description = mJoke.getTitle(); thumb = BitmapUtil.getThumbBitmapFromCache(mJoke.getImgUrl(), 100, 100); break; } msg.thumbData = ImgUtil.bmpToByteArray(thumb, true); SendMessageToWX.Req req = new SendMessageToWX.Req(); req.transaction = buildTransaction("webpage"); req.message = msg; req.scene = scene; api.sendReq(req); thumb.recycle(); }
Example #7
Source File: WxShareInstance.java From ShareUtil with Apache License 2.0 | 4 votes |
@Override public void shareMedia( final int platform, final String title, final String targetUrl, final String summary, final ShareImageObject shareImageObject, final Activity activity, final ShareListener listener) { Observable.fromEmitter(new Action1<Emitter<byte[]>>() { @Override public void call(Emitter<byte[]> emitter) { try { String imagePath = ImageDecoder.decode(activity, shareImageObject); emitter.onNext(ImageDecoder.compress2Byte(imagePath, TARGET_SIZE, THUMB_SIZE)); } catch (Exception e) { emitter.onError(e); } } }, Emitter.BackpressureMode.DROP) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doOnRequest(new Action1<Long>() { @Override public void call(Long aLong) { listener.shareRequest(); } }) .subscribe(new Action1<byte[]>() { @Override public void call(byte[] bytes) { WXWebpageObject webpageObject = new WXWebpageObject(); webpageObject.webpageUrl = targetUrl; WXMediaMessage message = new WXMediaMessage(webpageObject); message.title = title; message.description = summary; message.thumbData = bytes; sendMessage(platform, message, buildTransaction("webPage")); } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { activity.finish(); listener.shareFailure(new Exception(throwable)); } }); }