

#ANDROID SETTING ALWAYS UNLOX ANDROID#
* In Android 11 Build 30 things are a lot different. * false if permissions are to be requested, true if they have already been granted. * "Allow only while the app is running gives just the location permission while in foreground. In the case of location, the "Allow all the time" gives background permission When the user presses ok, Android will popup separate dialogs for each permission * This method lists all the permissions needed and gives reasons for each of them in a single I could not find a way to avoid cycling through the permissions twice. I am a little embarrassed to add my code because I know it sucks. of course the user may not select 'All the time'. Requesting both permissions gives the user the choice in the dialog box. Its only necessary in the 10+ versions of Android. But if I don't check, I dont get the "Allow all the time" option.

Interestingly, when I check if the background permission is already granted in the app, it never gives false. I had to provide an option for the user to grant it at start up, just like I need to do for the ACCESS_FINE_LOCATION. I found that adding just the permission in the manifest was not sufficient. If not, you'll need to request for the permissions by building an array of all of them and with a integer based request code : if (requireContext().checkSelfPermission(PERMISSION_NAME_1) != PackageManager.PERMISSION_DENIED & requireContext().checkSelfPermission(PERMISSION_NAME_2) != PackageManager.PERMISSION_DENIED. Once you have added these, you need to check in the code at some place if we have access to all of these permissions by below code block. You can keep all three of them or you can also remove either ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION but one of them mandatorily need to be there in Manifest file. To access location in background on device having android API level 29 or higher, you also need to add below permission in the manifest file.
