Peko
Peko copied to clipboard
Requesting ACCESS_BACKGROUND_LOCATION never completes
Hello there! Trying to gain background access. I learned that Peko, while requesting ACCESS_BACKGROUND_LOCATION, transitions user to the app permission settings only if ACCESS_FINE_LOCATION was previously gained, otherwise the flow does not emit anything. Is it intended behavior?
Steps to reproduce:
AndroidManifest:
<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" />
Activity's onCreate():
PermissionRequester.apply {
initialize(applicationContext)
lifecycleScope.launch {
repeatOnLifecycle(STARTED) {
try {
instance().request(
permission.ACCESS_BACKGROUND_LOCATION,
)
.catch {
Log.d("DEBUG_PERMISSIONS", "catch: $it")
}
.collect {
Log.d("DEBUG_PERMISSIONS", "$it")
}
} catch (e: Throwable) {
Log.d("DEBUG_PERMISSIONS", "error: $e")
}
}
}
}
Thanks for reporting this, I am looking into it.
I just tried it on Android 12 and I got the result Needs Rationale. This is for the clean app install, no prior permissions are given.
This happens with me as well , Requesting multiple permissions with requesting background location access results in Needs Rationale and Denies the rest of the permissions automatically without showing any kind of dialog [2024-03-30 02:51:12] Needs Rationale: ACCESS_BACKGROUND_LOCATION [2024-03-30 02:51:12] Denied Permanently: ACCESS_FINE_LOCATION [2024-03-30 02:51:12] Denied Permanently: ACCESS_COARSE_LOCATION [2024-03-30 02:51:12] Denied Permanently: POST_NOTIFICATIONS
I just tried to request all three location permissions at the same time and got the same result as you. But reading the official docs https://developer.android.com/develop/sensors-and-location/location/permissions and their examples of requesting location, they request only ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION in the same permission request Also they say
Types of location access
Each permission has a combination of the following characteristics:
Category: Either [foreground location](https://developer.android.com/develop/sensors-and-location/location/permissions#foreground) or [background location](https://developer.android.com/develop/sensors-and-location/location/permissions#background).
[Accuracy](https://developer.android.com/develop/sensors-and-location/location/permissions#accuracy): Either precise location or approximate location.
When I try to request ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION with Peko I get the Request popup and the result is not Denied Permanently