Request Background location permission settings tab in android 11

Viewed 1264

in android 11 (API 30) you can't request the permission ACCESS_BACKGROUND_LOCATION directly from the requestPermissions() method.. and instead, you need to enable it from the settings. On the Android Developers website: https://developer.android.com/training/location/permissions they say you can call getBackgroundPermissionOptionLabel() to get the settings label of the location permission. The documentation is limited and lacks specification of the getBackgroundPermissionOptionLabel() method and I don't know what to do. Does anyone know how to use this method?

1 Answers

getBackgroundPermissionOptionLabel() gives you a localized string that you can use to get the label of the option to "Allow all the time".

It is quite hard to request background location permission and dealing with the order of the permissions, rationales, and permanent denials. I would suggest having a look at the library I have been working on for a while for asking for permissions where this is included: https://github.com/warting/permissions-ui

Related