Peko icon indicating copy to clipboard operation
Peko copied to clipboard

Requesting ACCESS_BACKGROUND_LOCATION never completes

Open yozhiqueAtMTS opened this issue 2 years ago • 4 comments

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")
            }
        }
    }
}

yozhiqueAtMTS avatar Sep 20 '23 15:09 yozhiqueAtMTS

Thanks for reporting this, I am looking into it.

deva666 avatar Sep 21 '23 17:09 deva666

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.

deva666 avatar Sep 25 '23 07:09 deva666

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

codeslu avatar Mar 30 '24 01:03 codeslu

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

deva666 avatar Apr 03 '24 09:04 deva666