Prompting for location permission when NOT monitoring in background?
To clarify the requirement is different depending on whether you set targetSdkVersion 23
in your build.gradle file.
If you target SDK 23 (Marshmallow) or higher:
- You must declare android.permission.ACCESS_COARSE_LOCATION or android.permission.ACCESS_FINE_LOCATION in your manifest.
- You must prompt a user for permission as described in my blog post here.
- The user must accept this permission and not turn it off.
- If any of the above requirements are not met, you won't be able to detect beacons in the foreground or the background.
If you target SDK 22 or lower:
- You may optionally declare android.permission.ACCESS_COARSE_LOCATION or android.permission.ACCESS_FINE_LOCATION in your manifest.
- The user may turn on or off the permission by going to settings.
- If one of the permissions is not granted, you will still be able to detect beacons in the foreground, but not in the background.
See here and here for more details.