tbruyelle / RxPermissions

Android runtime permissions powered by RxJava2
Apache License 2.0
10.48k stars 1.31k forks source link

Android Q Location Permission Request #292

Open HaiLe opened 5 years ago

HaiLe commented 5 years ago

Hello,

this is a new behavior with Android Q when using rxpermissions for location request. When you select Allow all the time or Allow only while using the app, the app is dismissed and onNext() method is not triggered.

the next time you open the app again, it works fine.

Could you take a look and fix this for Q?

Pixel_XL

new RxPermissions(activity).request(Manifest.permission.ACCESS_FINE_LOCATION)
                .subscribe(new PMSubscriber<Boolean>() {
                    @Override
                    public void onError(Throwable e) {}

                    @Override
                    public void onNext(Boolean granted) {
                        if (granted) {

                        } else {

                        }
                    }
                });
DannyThompson commented 5 years ago

@HaiLe I ran into this as well! After playing around with it for a bit, I discovered that in Q in general if you want to request FINE location you have to have COARSE already granted, or request that as well, so if you call .requestEach(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION) instead of just .request(Manifest.permission.ACCESS_FINE_LOCATION), you should be fine.

JVilelaSmith commented 4 years ago

@HaiLe and @DannyThompson, I have been looking at this new location permission and the popup with the 3 options is only shown when I request
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> If this permission is not requested the popup only has 2 options: "Allow only while the app is in use" and "Deny".

In order to have the option "Allow all the time" we need to add the <uses-permission <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

I am using the following: rxPermissions.requestEachCombined(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION)

If we choose the option "Allow only while the app is in use" the callback that I get from rxpermissions is "permission.shouldShowRequestPermissionRationale" set as true.

Any ideas on this? How can we handle the 3 options, specially the "Allow only while the app is in use"?

Thanks!