"Allow all the time" location prompt not coming in Android SDK 29

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.

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

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.

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. 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 ...) {
    requestPermissions(@NonNull String[] permissions, int requestCode)

In order to access the location in background on device running Android 10 (API level 29) or higher, you also need to use below permission in the manifest file

 <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

please refer the below link for more information

https://developer.android.com/training/location/permissions?hl=fr


Add permission ACCESS_BACKGROUND_LOCATION in the manifest. It is required to show always allow option on android 10 and higher.

See the second point in https://developer.android.com/training/location/background#evaluate