public void shareImageToWx(final String imgUrl, String title, String desc, final int wxSceneSession) {
Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher);
WXImageObject imgObj = new WXImageObject(bmp);
final WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = imgObj;
msg.title = title;
msg.description = desc;
// final Bitmap[] thumbBmp = {Bitmap.createScaledBitmap(bmp, 150, 150, true)};
// bmp.recycle();
new Thread(new Runnable() {
@Override
public void run() {
try {
InputStream imageStream = getImageStream(imgUrl);
Bitmap bitmap = BitmapFactory.decodeStream(imageStream);
msg.mediaObject = new WXImageObject(bitmap);
//thumbBmp[0] = Bitmap.createScaledBitmap(bitmap, 150, 150, true);
bitmap.recycle();
} catch (Exception e) {
e.printStackTrace();
}
//msg.thumbData = bmpToByteArray(thumbBmp[0], true);
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("img");
req.message = msg;
req.scene = wxSceneSession;
api.sendReq(req);
}
}).start();
}
[code=java][/code]
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/131614.html
標籤:Android
上一篇:網路時間獲取筆記
