美文网首页Android技术知识
解决Android微信分享二维码不能长按识别问题

解决Android微信分享二维码不能长按识别问题

作者: Owater | 来源:发表于2016-10-13 17:52 被阅读438次

问题描述

Android使用微信分享SDK分享二维码图片,Android系统上是先下载这张图片,然后才能打开,但是长按却识别不了二维码,不过在IOS上是正常的,可以长按识别,所以这是微信Android版的一个bug

解决方案

既然微信SDK不行,那我们就不使用它,使用另外一种分享方式,通过Android Intent去分享

Intent shareIntent = new Intent(Intent.ACTION_SEND);                
String imgPath = getShareImgPath();
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.setComponent(new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareImgUI"));
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+imgPath));                
startActivity(shareIntent);

setComponent方法是过滤掉其它应用,只选择分享给某个人

相关文章

网友评论

    本文标题:解决Android微信分享二维码不能长按识别问题

    本文链接:https://www.haomeiwen.com/subject/quowyttx.html