Reputation: 43
I have a Delphi app that I am trying to make compatible with Android 11 devices and am stumbling a bit with External Storage permissions. I am able to request the permission which opens the screen outside the app and granting it that way works fine.
The problem I am encountering is that after every device reboot I have to ask for and grant the permission again. Is there a way to avoid this?
I know that the restriction of the file access is a security precaution, but this app will never be published in the PlayStore.
I did find a lot of different information about how to request the permission itself, but nothing about the problem of having to re-request it every time after the Device gets rebooted. At one point I was told this was normal behavior, but I want to make sure and ask, if that is really the case.
This is the code I am using to ask for the permission:
var PackageName := TJnet_Uri.JavaClass.fromParts(StringToJString('package'), TAndroidHelper.Context.getPackageName, nil);
var intent := TJIntent.JavaClass.init(StringToJString('android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION'), PackageName);
intent.setData(PackageName);
TAndroidHelper.Context.startActivity(intent);
And made sure that
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
are part of the manifest.
Can I keep the permission once it has been granted even through device reboots?
Upvotes: 0
Views: 194