Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 13适配问题 #2623

Closed
shannontech opened this issue Mar 15, 2023 · 6 comments
Closed

Android 13适配问题 #2623

shannontech opened this issue Mar 15, 2023 · 6 comments

Comments

@shannontech
Copy link

shannontech commented Mar 15, 2023

Current use version?

当前使用的版本是多少?

v3.10.8

Will this problem occur in demo?

Demo能否复现这问题?

Describe the problem or provide an error log?

描述问题或提供错误log?

-当把demo的targetSdkVersion调至33(Android 13)后,在Android 13的设备(真机&模拟器)上运行,选取图片功能失效(确认已授予android.permission.READ_MEDIA_IMAGES权限)。
-现象是:点击+号之后——跳至图片选择页——选择页是空的——直接自动跳至了系统权限页(可以看到图片权限是已经授予的)——退出系统权限页——返回提示Read memory card access denied。用模拟器和真机都是这个现象。Android 13无法选取图片。

注:在targetSdkVersion小于33时(Android 12及以下设备)可以正常运行,没有问题
image
image
image
image

@shannontech
Copy link
Author

shannontech commented Mar 15, 2023

我尝试修复了下,因为Android 13移除了READ_EXTERNAL_STORAGE权限。所以只要把com.luck.picture.lib.permissions.PermissionChecker#isCheckReadStorage方法里面,关于PermissionChecker.isCheckReadExternalStorage的判断删去就可以了。
image

@mobilewhj
Copy link

遇见了同样的情况。

@whatisjava
Copy link

把这个加上试试:

private class OnPermissionsInterceptListenerImpl: OnPermissionsInterceptListener {
override fun requestPermission(fragment: Fragment?, permissionArray: Array?, call: OnRequestPermissionListener?) {
if (permissionArray == null || fragment == null || fragment.context == null) return
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
val result = permissionArray.toMutableList()
if (permissionArray.contains(Manifest.permission.READ_EXTERNAL_STORAGE)) {
result.remove(Manifest.permission.READ_EXTERNAL_STORAGE)
}
call?.onCall(result.toTypedArray(), true)
} else {
call?.onCall(permissionArray, true)
}
}

    override fun hasPermissions(fragment: Fragment?, permissionArray: Array<out String>?): Boolean {
        if (permissionArray == null || fragment == null) return false
        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
            val result = permissionArray.toMutableList()
            if (permissionArray.contains(Manifest.permission.READ_EXTERNAL_STORAGE)) {
                result.remove(Manifest.permission.READ_EXTERNAL_STORAGE)
            }
            EasyPermissions.hasPermissions(
                fragment.context,
                *result.toTypedArray().toCompatPermissions
            )
        } else {
            EasyPermissions.hasPermissions(
                fragment.context,
                *permissionArray.toCompatPermissions
            )
        }
  }

}

@aa86799
Copy link

aa86799 commented Mar 28, 2023

源码里的,PermissionConfig#getReadPermissionArray() ,也有 READ_EXTERNAL_STORAGE 相关判断,把它也注释掉。然后,可以在调用 PictureSelector 的地方 ,手动添加权限判断

@LuckSiege
Copy link
Owner

v3.10.9已修复

@whatisjava
Copy link

您好,请问3.10.9 发mavencenter了吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants