RxPermission: java.lang.IllegalStateException: RealRxPermission.onRequestPermissionsResult invoked but didn't find the corresponding permission request.
On some phones when requesting the WRITE_EXTERNAL_STORAGE permission i am getting:
Fatal Exception: java.lang.RuntimeException: Unable to resume activity {io.soulpicks.android.beta/com.vanniktech.rxpermission.ShadowActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=42, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {io.soulpicks.android.beta/com.vanniktech.rxpermission.ShadowActivity}: java.lang.IllegalStateException: RealRxPermission.onRequestPermissionsResult invoked but didn't find the corresponding permission request.
at android.app.ActivityThread.performResumeActivity(ActivityThread.java)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$900(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
This is what I use to call it:
permissionManager.request(WRITE_EXTERNAL_STORAGE)
.subscribeOn(schedulerProvider.newThread())
.observeOn(schedulerProvider.ui())
.subscribeBy(onSuccess = {
permissionRequest.value = it
},
onError = {
permissionRequest.value = Permission.denied(WRITE_EXTERNAL_STORAGE)
})
.addTo(disposables)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (14 by maintainers)
Yep, fine with me! 🙌
I think it’s not even an issue of ShadowActivity vs. retained fragment. Using a cold Observable that triggers the permission request on subscribe and emits the result is, in my opinion, not the right abstraction. Permission results are a hot observable, since they can be emitted “before” the request.
It works for the request-in-
onCreatecase, but maybe the sample should be updated with that in mind.Sure, I can have a look! Not sure when I’ll have time yet, hopefully soon.
On Thu, Nov 22, 2018 at 11:43 AM Niklas Baudy notifications@github.com wrote:
– Hannes Struß
Freelance Android Engineer @hannesstruss https://twitter.com/hannesstruss