1

Im investigating the File access changes associated with Android 11

I've configured an AVD fro Android R and created a Test Application that has the following Manifest contents

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.my.application">

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

I then create this Intent and start Activity expecting to see the Allow access to manage all files. in System Settings

    val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
    val uri = Uri.fromParts("package", packageName, null)
    intent.data = uri
    startActivity(intent)

However the user is presented with the App Info screen for my test application.

If I search in settings I can find the Apps & Notifications -> Special App Access -> All files access -> My test app is listed

Is this the process users have to follow to grant this permission?

Why doesnt using the Intent I constructed take the User directly to the All Files Access page?

Hector
  • 4,016
  • 21
  • 112
  • 211
  • Please See this way in this link , It can be useful. https://stackoverflow.com/a/67140033/12272687 – Mori Apr 17 '21 at 16:01
  • Please See this way in this link , It can be useful. https://stackoverflow.com/a/67140033/12272687 It can help to read/write access for all files – Mori Apr 17 '21 at 16:18

2 Answers2

3

Implementing an intent for

  Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION 

will give your app read/write access for all files even on removable micro sd card.

blackapps
  • 8,011
  • 2
  • 11
  • 25
1
if (SDK_INT >= Build.VERSION_CODES.R) {
        if (!Environment.isExternalStorageManager()) {
            Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
            Uri uri = Uri.fromParts("package", getPackageName(), null);
            intent.setData(uri);
            startActivity(intent);
        }
    } else {
        //below android 11=======
        startActivity(new Intent(this, ActivityPicture.class));
        ActivityCompat.requestPermissions(this, new String[]{WRITE_EXTERNAL_STORAGE}, 100);
    }

Also add this to manifest :

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103