微信登录分享报错详解

最近在接入微信原生安卓登录以及分享图片 
一开始登录报错 错误码 -6 后来发现是debug.keystore 不对 搞定之后发现 分享网页直接报错 
提示错误为(checkArgs fail, thumbData is invalid)
搜索后发现为图片大小不对 限制32kb 查看项目并不对 后来发现代码有个缩略图设置没有这只 
原代码为 

Bitmap thumb = BitmapFactory.decodeResource(getResources(), R.drawable.send_music_thumb);
直接报错
 
  
修改后可以分享



WXWebpageObject webpage = new WXWebpageObject();
							webpage.webpageUrl = "http://www.baidu.com";
							WXMediaMessage msg = new WXMediaMessage(webpage);
							msg.title = "WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title WebPage Title Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long Very Long";
							msg.description = "WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description WebPage Description Very Long Very Long Very Long Very Long Very Long Very Long Very Long";
							Bitmap thumb = BitmapFactory.decodeResource(getResources(), R.drawable.send_music_thumb);
							Bitmap thumbBmp = Bitmap.createScaledBitmap(thumb, THUMB_SIZE, THUMB_SIZE, true);
							thumb.recycle();
							msg.thumbData = Util.bmpToByteArray(thumbBmp, true);
							
							SendMessageToWX.Req req = new SendMessageToWX.Req();
							req.transaction = buildTransaction("webpage");
							req.message = msg;
							req.scene = isTimelineCb.isChecked() ? SendMessageToWX.Req.WXSceneTimeline : SendMessageToWX.Req.WXSceneSession;
							api.sendReq(req);


你可能感兴趣的:(SDK接入)