简体   繁体   English

API 33 Android 13 未找到非媒体文件

[英]API 33 Android 13 non-media files not found

I am developing an app for API 33, Android 13, and non-media files are not found.我正在为 API 33、Android 13 开发应用程序,但未找到非媒体文件。 According to Google, you do not need permissions to find non-media files, but these are not found, even with permissions set.根据谷歌的说法,您不需要权限来查找非媒体文件,但即使设置了权限也找不到这些文件。 Until Android 12, I got the option for "Allow management of all Files", but in Android 13, this is not possible.直到Android 12,我得到了“允许管理所有文件”的选项,但是在Android 13,这是不可能的。

When I recursively scan.bin and.png files, in Android 12 and 13, it finds both in 12, but only finds.png in 13. I do see the.bin file with the Files application in 13.当我递归扫描 .bin 和 .png 文件时,在 Android 12 和 13 中,它在 12 中找到了两个,但在 13 中只找到了 .png。我确实在 13 中看到了带有文件应用程序的 .bin 文件。

<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />

These won't work, any suggestions how to find the.bin file?这些都行不通,有什么建议可以找到 .bin 文件吗? I put the files on我把文件放在

/storage/
/sdcard/

It's possible to request all files permissions and then the.bin file was found on the sdcard.可以请求所有文件权限,然后在 sdcard 上找到 .bin 文件。 Tested on API 29, 31, 33.测试于 API 29、31、33。

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
        tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

MainActivity主要活动

private void checkForExternalPermission() {
  if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
    if (!checkStoragePermission()) {
      PermissionActivity.requestStoragePermission(this, true);
    }
  } else {
    PermissionActivity.requestAllFilesAccess(this);
  }
}

PermissionActivity权限活动

For storage permission < Android 13对于存储权限 < Android 13

startActivity(
  new Intent(
    android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
    Uri.parse(String.format("package:%s", getPackageName()))));

PermissionActivity权限活动

For all files permissions Android 13对于所有文件权限 Android 13

Intent intent =
  new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
  .setData(Uri.parse("package:" + getPackageName()));
startActivity(intent);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM