收藏
回答

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
回答关注问题邀请回答
收藏

3 个回答

登录 后发表内容
问题标签