别裁伪体亲风雅,转益多师是汝师。这篇文章主要讲述Android 微信网址分享添加网络图片相关的知识,希望能为你提供帮助。
public static void share(String CustomEventData,String title,String titlle_detail,String imgUrl)throwsMalformedURLException{Log.e(TAG,"share##########################"); Log.e(TAG,imgUrl); WXWebpageObject webpage=newWXWebpageObject(); webpage.webpageUrl="https://fir.im/5et2"; WXMediaMessage msg=newWXMediaMessage(webpage); msg.title=title; msg.description=titlle_detail; //加载本地图片// Bitmap thumb = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.zhuye_tip); // msg.setThumbImage(thumb); // thumb.recycle(); //加载网络图片********//注意下方的压缩try{Bitmap thumb=BitmapFactory.decodeStream(new URL(imgUrl).openStream()); //注意下面的这句压缩,120,150是长宽。//一定要压缩,不然会分享失败Bitmap thumbBmp=Bitmap.createScaledBitmap(thumb,120,150,true); //Bitmap回收thumb.recycle(); msg.thumbData=https://www.songbingjia.com/android/Util.bmpToByteArray(thumbBmp,true); // msg.setThumbImage(thumb); }catch(IOException e){e.printStackTrace(); }Log.e(TAG,msg.title); Log.e(TAG,msg.description); //构造ReqSendMessageToWX.Req req=newSendMessageToWX.Req(); req.transaction=buildTransaction("webpage"); req.message=msg; Log.e(TAG,CustomEventData); if(Integer.parseInt(CustomEventData)==0){req.scene=SendMessageToWX.Req.WXSceneSession; }else{req.scene=SendMessageToWX.Req.WXSceneTimeline; }api.sendReq(req); //发送到微信Log.e(TAG,"share###### END ####################"); }
【Android 微信网址分享添加网络图片】
推荐阅读
- Microsoft Azure Tutorial: Build your first movie inventory web app with just a few lines of code(示例代
- Android 微信分享图片
- tcp_wrapper
- Android 检查手机上是否安装了指定的软件(根据包名检测)
- AutoMapper 使用心得
- Android 控制硬加速 hardwareAccelerated
- SpringMVChandleMapping 处理器映射器 属性清单
- Debugging QML Applications
- Android性能优化之布局优化