Skip to content

Instantly share code, notes, and snippets.

@fredchung
Created September 7, 2020 06:07
Show Gist options
  • Save fredchung/f46ca3b64e0b3a02806cbb6790275583 to your computer and use it in GitHub Desktop.
Save fredchung/f46ca3b64e0b3a02806cbb6790275583 to your computer and use it in GitHub Desktop.
Do not request foreground and background location permissions together (Activity library).
// Using Activity library.
val requestPermissionsLauncher =
registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
map: MutableMap<String, Boolean> ->
...
}
...
requestPermissionsLauncher.launch(
arrayOf(
// Do not request foreground and background location permissions together,
// as they will be ignored along with any other permissions in the request.
// Request location permissions incrementally instead.
android.Manifest.permission.ACCESS_COARSE_LOCATION,
android.Manifest.permission.ACCESS_BACKGROUND_LOCATION,
...)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment