我的应用程序目标api级别为32。当在Android 13设备上运行时,ActivityResultContracts.RequestMultiplePermissions()总是返回PERMISSION_DENIED,即使用户按下"Allow"
同样,当检查设置->app->权限时,图像,音频和视频权限被授予。
文档明确指出,针对api级别的应用程序;33应该继续请求READ_EXTERNAL_DEVICE,并且IMAGE, AUDIO和VIDEO将自动授予
尝试允许READ_EXTERNAL_STORAGE权限。
画廊即将开放
实际上,权限被拒绝了。
显然,从android 13及以上你需要把权限READ_MEDIA_VIDEO,READ_MEDIA_IMAGES,READ_MEDIA_AUDIO,不只是请求READ_EXTERNAL_STORAGE将单独工作,甚至不会显示在权限页面的设置
<!-- Required only if your app needs to access images or photos
that other apps created. -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<!-- Required only if your app needs to access videos
that other apps created. -->
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<!-- Required only if your app needs to access audio files
that other apps created. -->
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<!-- If your app doesn't need to access media files that other apps created,
set the "maxSdkVersion" attribute to "28" instead. -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />