From Android Docs, https://developer.android.com/training/data-storage/manage-all-files#all-files-access
"An app can request All files access from the user by doing the following:
Declare the MANAGE_EXTERNAL_STORAGE permission in the manifest.
Use the ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION intent action to direct users to a system settings page where they can enable the following option for your app: Allow access to manage all files."
The only way I know how to request permissions is with ActivityCompat
. I've tried:
ActivityCompat.requestPermissions(this, new String[]{Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION},1);
and
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.MANAGE_EXTERNAL_STORAGE},1);
Neither of which do anything.
The Android docs are extensive but not exactly the most welcoming for newcomers. I understand intents, and know they can be used to switch between activities, but I don't know what an "intent action" is and how it can be used to request permissions
On the Settings > Privacy > Permission manager > Files and media page, each app that has the permission is listed under Allowed for all files. If your app targets Android 11, keep in mind that this access to "all files" is read-only.
On your phone, open the Settings app. Permission manager. Tap a permission type. If you allowed or denied permission to any apps, you'll find them here.
MANAGE_EXTERNAL_STORAGE. Backup and restore apps. App must have a need to automatically access multiple directories outside of its app-specific storage space for the purpose of backup and restore. Anti-virus apps. App's core purpose is to scan the device and provide anti-virus security features to the device user.
In Kotlin:
val uri = Uri.parse("package:${BuildConfig.APPLICATION_ID}")
startActivity(
Intent(
Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION,
uri
)
)
(from this sample project)
You are probably used to an implicit Intent
(Intent(this, SomeActivity::class.java)
). The docs are asking you to use an explicit Intent
, one with an action string and, in this case, a Uri
. The Uri
will have the package
scheme and identify your app by its application ID.
That code snippet will start a system-supplied activity that, in theory, will let the user opt into granting your app the MANAGE_EXTERNAL_STORAGE
permission.
The Android docs are extensive but not exactly the most welcoming for newcomers
You might wish to consider reading a book or taking a course. Any decent book or course will cover the concept of Intent
actions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With