微信分享图片,偶尔无法调起?
发布于 5 年前 作者 liangyan 4263 次浏览 来自 问答

微信版本7.0.12

Android版本:Android10

说明:imgObj.checkArgs()返回true,要分享的图片大小没问题,缩略图也没问题。适配fileprovider使用app的cache目录保存的图片,然后分享的图片路径,否则使用的bitmap分享

IWXAPI api = WXAPIFactory.createWXAPI(activity.getApplicationContext(), OtherConfig.WE_CHAT_APP_ID, true);
        api.registerApp(OtherConfig.WE_CHAT_APP_ID);
        if (!api.isWXAppInstalled()) {
            T.ss("未检测到您的微信客户端");
            return false;
        }

        //初始化 WXImageObject 和 WXMediaMessage 对象
        WXImageObject imgObj = new WXImageObject();
        long imagePathFileLength = 0L;
        if (checkVersionValid(api) && checkAndroidNotBelowN()) {
            File directory = BitmapUtil.getCacheDirectory(activity);
            File outFile = new File(directory, "share_" + System.currentTimeMillis() + ".jpg");
            try {
                BitmapUtil.saveBitmap(imageData, outFile);
                imgObj.imagePath = getFileUri(activity, outFile);
                // 使用contentPath作为文件路径进行分享
                // ...
            } catch (IOException e) {
                ToastUtils.showText("分享失败,请稍候重试");
            }
            imagePathFileLength = outFile.length();
        } else {
            imgObj.imageData = BitmapUtil.bitmapToByte(imageData);
        }

        WXMediaMessage msg = new WXMediaMessage();
        msg.mediaObject = imgObj;

        imageData.recycle();
        msg.thumbData = result;
        //构造一个Req
        SendMessageToWX.Req req = new SendMessageToWX.Req();
        req.transaction = "img";
        req.message = msg;
        req.scene = scene;
//        req.openId = getOpenId();
        //调用api接口,发送数据到微信
        api.sendReq(req);

2020-12-09 21:01:43.795 22629-22966/? E/libc: Access denied finding property “persist.sys.theme.color”

2020-12-09 21:01:43.799 22629-22966/? E/libc: Access denied finding property “persist.sys.theme.color”

2020-12-09 21:01:43.799 22629-22966/? E/libc: Access denied finding property “persist.sys.theme.colortone”

2020-12-09 21:01:44.316 23594-23594/? E/com.tencent.mm: Not starting debugger since process cannot load the jdwp agent.

2020-12-09 21:01:44.374 23594-23594/? E/libc: Access denied finding property “persist.sys.theme.color”

2020-12-09 21:01:44.375 23594-23594/? E/libc: Access denied finding property “persist.sys.theme.color”

2020-12-09 21:01:44.393 23594-23594/? E/libc: Access denied finding property “persist.sys.theme.color”

2020-12-09 21:01:45.295 23619-23619/? E/com.tencent.mm: Not starting debugger since process cannot load the jdwp agent.

2020-12-09 21:01:45.321 23619-23619/? E/libc: Access denied finding property “persist.sys.theme.color”

2020-12-09 21:01:45.322 23619-23619/? E/libc: Access denied finding property “persist.sys.theme.color”

2020-12-09 21:01:45.357 23619-23619/? E/libc: Access denied finding property “persist.sys.theme.color”

2020-12-09 21:01:45.394 23619-23619/? E/ActivityThread: Failed to find provider info for com.tencent.mm.coolassist.debugprovider

2020-12-09 21:01:45.615 23619-23619/? E/libprocessgroup: set_timerslack_ns write failed: Operation not permitted

2020-12-09 21:01:45.958 23619-23676/? E/libc: Access denied finding property “ro.vendor.scroll.preobtain.enable”

2020-12-09 21:01:45.971 23619-23676/? E/libc: Access denied finding property “ro.vendor.scroll.preobtain.enable”

2020-12-09 21:01:46.001 23619-23676/? E/libc: Access denied finding property “ro.vendor.scroll.preobtain.enable”

2020-12-09 21:01:46.030 23619-23672/? E/com.tencent.mm: No implementation found for java.util.ArrayList com.tencent.mars.smc.SmcLogic.getLoadLibraries() (tried Java_com_tencent_mars_smc_SmcLogic_getLoadLibraries and Java_com_tencent_mars_smc_SmcLogic_getLoadLibraries__)

2020-12-09 21:01:46.040 23619-23676/? E/libc: Access denied finding property “ro.vendor.scroll.preobtain.enable”

2020-12-09 21:01:46.048 23619-23676/? E/libc: Access denied finding property “ro.vendor.scroll.preobtain.enable”

2020-12-09 21:01:48.221 23619-23670/? E/ActivityThread: Failed to find provider info for com.huawei.android.launcher.settings

2020-12-09 21:01:48.235 23619-23670/? E/ActivityThread: Failed to find provider info for com.android.badge

2020-12-09 21:01:48.281 23619-23786/? E/ActivityThread: Failed to find provider info for com.android.badge

2020-12-09 21:01:48.899 10296-10405/? E/libc: Access denied finding property “net.dns1”

2020-12-09 21:01:48.899 10296-10405/? E/libc: Access denied finding property “net.dns2”

2020-12-09 21:01:49.026 10296-23814/? E/libc: Access denied finding property “net.dns1”

2020-12-09 21:01:49.026 10296-23814/? E/libc: Access denied finding property “net.dns2”

1 回复

看报错是手机没给相册权限?

回到顶部