Android Question [SOLVED] Android 10, 11 and Runtime Permissions

SimonInCanada

Member
Licensed User
I have several apps that had to be changed for the Android 6+ runtime permissions and this has been working well so far up to Android 8. My apps all need Android.permission.WRITE_EXTERNAL_STORAGE, android.permission.ACCESS_COARSE_LOCATION and android.permission.ACCESS_FINE_LOCATION.

I see (e.g. https://www.androidauthority.com/android-11-features-1085228/) that Android 10 and 11 are supposed to:
ask you if you want to grant the app permissions all the time, only when you’re using the app, or not at all. This was a big step forward, but Android 11 gives the user even more control by allowing them to give permissions only for that specific session
.

And further, that article says
If a user gives permission for the session, once they close the app, Android will revoke that permission. If a user wants to grant permission every time they use the app, that option is still there, but an option to grant permission all the time won’t be available for a lot of apps. This will make things much safer for users and make it much more difficult for sneaky apps to collect the information you might not want them to collect. Similarly, Android 11 will now “auto-reset” apps you haven’t used in a while. If you granted location data permissions to an app that you haven’t opened up in a long time, Android will now revoke all permissions. Next time you open the app, you’ll need to approve those permissions again.

Has anybody found they needed to make any changes to their apps to accomodate this?
 

agraham

Expert
Licensed User
Longtime User
This thread summaries the changes you might need to make.
In particular the lack of WRITE_EXTERNAL_STORAGE may cause you problems. Targeting API 30 and above means that if you REALLY need to access outside your protected folders then you will need to use the External Storage class to do so.

Note that if you are not putting your app in the Play Store then you don't need to target above SDK 28 unless you really need to. There is the manifest work around for SDK 29 and in SDK 30 a new MANAGE_EXTERNAL_STORAGE permission that still lets you use legacy external storage access, but this will not be accepted for a Play Store app unless it is really required for the apps main functionality.
 
Upvote 0

SimonInCanada

Member
Licensed User
This thread summaries the changes you might need to make.
In particular the lack of WRITE_EXTERNAL_STORAGE may cause you problems. Targeting API 30 and above means that if you REALLY need to access outside your protected folders then you will need to use the External Storage class to do so.

Note that if you are not putting your app in the Play Store then you don't need to target above SDK 28 unless you really need to. There is the manifest work around for SDK 29 and in SDK 30 a new MANAGE_EXTERNAL_STORAGE permission that still lets you use legacy external storage access, but this will not be accepted for a Play Store app unless it is really required for the apps main functionality.

Thanks. That is very helpful I did try searching before posting but must have used the wrong key words. There are and will only ever be only a few tens of users as the apps are all used to support various low-volume, high value equipment. Hence I often don't even look at Android for months at a time (too busy with embedded stuff).

Simon M
 
Upvote 0

SimonInCanada

Member
Licensed User
Why do you need external storage? Usually you won't need any other than dir.internal. Let the user share the data TO or FROM your app (sarch for examples in the forum).

Thanks. I haven't fully read all of AGraham's links yet but this had already crossed my mind. The original objective of external storage (about 5-6 years ago) was to allow all the app's log data to be written to an SD card because one of the managers thought it would be a good idea and as it was easy to do I did not object. Now, if it is likely to cause any problems now or in the future, the simplest solution is probably just to move it to internal and instruct the users to offload any existing data before upgrading.

I am unsure what you mean by letting users share data TO and FROM our app(s). I did search for examples but they seemed to be about using SQL Lite?

Simon M
 
Upvote 0

SimonInCanada

Member
Licensed User
Start here: https://www.b4x.com/android/forum/threads/sharing-files-from-your-app-with-file-provider.70458/

You can share it then to a mail app. Like you can share pics to facebook.

Another way: upload the file with sftp or OKHttputils or through network... Many ways...

Thanks. That's interesting. For my immediate requirements however, the only reason the apps are using the WRITE_EXTERNAL_STORAGE permission is to save log and setup data to an SD Card rather than the phone's internal storage; a management decision made years ago and not really necessary now, if it ever was. So I am going to go with your first idea of using internal storage.

Simon M
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
To write on the external SDCard or USB-Sticks on higher Androids you need to use the External Storage Class.
 
Upvote 0

SimonInCanada

Member
Licensed User
Thanks to everyone who has replied so quickly and given me pointers to such great information. I think I understand the options now :)

Simon M
 
Upvote 0
Top