BGAQRCode-Android
BGAQRCode-Android copied to clipboard
targetSdkVersion29在Android 10手机识别本地相册二维码返回null
targetSdkVersion29在Android 10手机识别本地相册二维码返回null,同时相册打开也是看不到图片。
<manifest ... >
<!-- This attribute is "false" by default on apps targeting
Android 10 or higher. -->
<application android:requestLegacyExternalStorage="true" ... >
...
</application>
</manifest>
同理,我也遇到这样的问题
10.0扫描相册为null
我的也是,开始以为我的二维码有问题 ,但是我拍了很多张都是这样
原因是cn.bingoogolapple.qrcode.core.BGAQRCodeUtil中public static Bitmap getDecodeAbleBitmap(String picturePath)方法内部对图片进行了压缩,导致失败失败,可以将下面int sampleSize = options.outHeight / 400;中sampleSize值改小点就可以了 public static Bitmap getDecodeAbleBitmap(String picturePath) { try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(picturePath, options); int sampleSize = options.outHeight / 400; if (sampleSize <= 0) { sampleSize = 1; } options.inSampleSize = sampleSize; options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(picturePath, options);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}