- oppo手机微信分享调不起微信
app采用微信分享的时候,在oppo手机上调不起微信。其它手机正常。 public void share(int flag, String shareUrl, String shareTitle, String shareDesc) { //初始化一个WXWebpageObject,填写url WXWebpageObject webpage = new WXWebpageObject(); webpage.webpageUrl = shareUrl; //用 WXWebpageObject 对象初始化一个 WXMediaMessage 对象 WXMediaMessage msg = new WXMediaMessage(webpage); msg.title = shareTitle; msg.description = shareDesc; Bitmap thumbBmp = BitmapFactory.decodeResource(weakReference.get().getResources(), R.mipmap.small_logo); msg.thumbData = bmpToByteArray(thumbBmp, true); //构造一个Req SendMessageToWX.Req req = new SendMessageToWX.Req(); req.transaction = String.valueOf(System.currentTimeMillis()); req.message = msg; if (flag == 0) { req.scene = SendMessageToWX.Req.WXSceneSession;//分享到微信好友 } else if (flag == 1) { req.scene = SendMessageToWX.Req.WXSceneTimeline;//分享到微信朋友圈 } req.userOpenId = ConfigUtil.wechatAppId; //调用api接口,发送数据到微信 boolean end = iwxapi.sendReq(req); Log.e("...", end + ""); } public byte[] bmpToByteArray(final Bitmap bmp, boolean needRecycle) { ByteArrayOutputStream output = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 50, output); if (needRecycle) { bmp.recycle(); } byte[] result = output.toByteArray(); try { output.close(); } catch (Exception e) { e.printStackTrace(); } return result; }zh这是两个方法。end返回false
2021-03-09 - 微信小程序扫描二维码success返回结果异常
调用系统的扫码wx.scanCode方法,在success方法中,做分割字符串操作。let a = []; a = res.result.split("|");这一句报错导致崩溃。错误日志如下: Cannot read property 'split' of null;at pages/my/my scan_onclick function;at api scanCode success callback function TypeError: Cannot read property 'split' of null at success (https://miniprogram:///pages/my/my.js:38:24) at Function.o.<computed> (https://lib/WASubContext.js:2:1311158) at y (https://lib/WASubContext.js:2:417494) at v (https://lib/WASubContext.js:2:417732) at https://lib/WASubContext.js:2:419286。 期待回复
2020-04-07