sceneSwitch.setDrawingCacheEnabled(true);//sceneSwitch是一个自定义的VIew
Bitmap bmp = Bitmap.createBitmap(sceneSwitch.getDrawingCache());//用这种方法就没办法跳出分享页面
//Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.send_img);//用这个bmp就可以跳出分享界面
WXImageObject imgObj = new WXImageObject(bmp);
WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = imgObj;
Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true);
bmp.recycle();
msg.thumbData = Util.bmpToByteArray(thumbBmp, true); // 设置缩略图
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("img");
req.message = msg;
req.scene = SendMessageToWX.Req.WXSceneTimeline;//判断是否发送到朋友圈
api.sendReq(req);
用微信官方的做的,新手求指导:从VIew获得图片没法跳出分享界面