tbruyelle / RxPermissions

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

Trouble with Android 11 and a new option for permissions "Only this time/Ask every time" #333

Open slobodanantonijevic opened 3 years ago

slobodanantonijevic commented 3 years ago

The problem is that with new Android 11 there is a new option (apart from "always" and "only in app") for permissions (eg. Location) which is "Only this time" or "Ask every time" depending on which screen you get it. The thing is the app with this set has to ask permission every time the user starts a new session in the app. However your library always returns permission as granted for this option chosen. While the permission should be reset every time the app is restarted.

galuszkak commented 3 years ago

Hi @slobodanantonijevic ,

Can you prepare a minimum working example of this issue? Generally speaking, if app was restarted when looking on permissions is should ask again for those, so I'm not fully sure what isn't working as expected.

VuHongKy commented 3 years ago

@galuszkak Yes, Android 11 (API = 30) has changed permissons a little, please update it, bro.

On my case, when confirm permission dialog show:

On my code, it always open permission settings like this:

fun FragmentActivity.requestRxPermissions(vararg permissions: String, granted: () -> Unit): Disposable {
    return RxPermissions(this)
            .requestEachCombined(*permissions)
            .autoDisposable(AndroidLifecycleScopeProvider.from(this, Lifecycle.Event.ON_DESTROY))
            .subscribe { permission ->
                when {
                    permission.granted -> granted()
                    permission.shouldShowRequestPermissionRationale -> {
                        // At least one permission is denied
                    }
                    else -> openPermissionSettings()
                }
            }
}
pk4393 commented 3 years ago

@galuszkak Any update on this issue?

the library always returns permission as granted for the "Ask every time" option. But as per the behavior of Android 11, the permission should be reset every time the app is restarted.

huutuan06 commented 2 years ago

@galuszkak Yes, Android 11 (API = 30) has changed permissons a little, please update it, bro.

On my case, when confirm permission dialog show:

  • On android 8.0, I click outside of confirm dialog -> nothing happened.
  • On android 11, I click outside of confirm dialog -> it jump to subscribe { } function and both permission.granted = false and permission.shouldShowRequestPermissionRationale = false

On my code, it always open permission settings like this:

fun FragmentActivity.requestRxPermissions(vararg permissions: String, granted: () -> Unit): Disposable {
    return RxPermissions(this)
            .requestEachCombined(*permissions)
            .autoDisposable(AndroidLifecycleScopeProvider.from(this, Lifecycle.Event.ON_DESTROY))
            .subscribe { permission ->
                when {
                    permission.granted -> granted()
                    permission.shouldShowRequestPermissionRationale -> {
                        // At least one permission is denied
                    }
                    else -> openPermissionSettings()
                }
            }
}

I have the same problem when user clicks outside the permission dialog. It's always jump to 'else -> openPermissionSettings()''. My expectation is only dialog disappears when user clicks outside. Do you have any solution for it or still keep this flow?