Jump to content
Sign in to follow this  
MMSoft

Request "Access All Files" Permission ?

Recommended Posts

I'm using Delphi 12.1 and have the option to give my App the option to "Access all files".

To do this, I check "Manage external storage" under Uses Permissions.

I will display the System Setup screen in which this permission data can be data.:

uses
 Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.Net;

var
 LIntent: JIntent, LUri: Jnet_Uri;

Begin
 LUri := TJnet_Uri.JavaClass.fromParts(StringToJString('package'), TAndroidHelper.Context.getPackageName, nil);
 LIntent := TJIntent.JavaClass.init(TJSettings.JavaClass.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, LUri);
 LIntent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);
 TAndroidHelper.Context.startActivity(LIntent);
end;


But how can I ask whether this Permission has been given ?

(sorry for my bad english)

Share this post


Link to post
7 minutes ago, MMSoft said:

But how can I ask whether this Permission has been given ?

With this:

uses
  Androidapi.JNI.Os;

LHasAccess := TJEnvironment.JavaClass.isExternalStorageManager;

Note that this applies from Android 11 onwards only, so you should use TOSVersion.Check(11) to determine whether or not to manage that permission

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×