question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.IllegalStateException: RealRxPermission.onRequestPermissionsResult invoked but didn't find the corresponding permission request.

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
hannesstrusscommented, Dec 26, 2018

Yep, fine with me! 🙌

using the ShadowActivity has its drawbacks.

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-onCreate case, but maybe the sample should be updated with that in mind.

1reaction
hannesstrusscommented, Nov 23, 2018

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:

That sounds good!

Mind taking a crack at this?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vanniktech/RxPermission/issues/51#issuecomment-440989340, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHCtQl4guW7rDWN7r446aE2iRkqX94Mks5uxn-3gaJpZM4W2poZ .

– Hannes Struß

Freelance Android Engineer @hannesstruss https://twitter.com/hannesstruss

Read more comments on GitHub >

github_iconTop Results From Across the Web

permissions - Android java.lang.IllegalStateException in ...
This Error is because the Activity State is Not Saved and you are ... to set a boolean flag in onRequestPermissionsResult and use...
Read more >
com.vanniktech.rxpermission.Permission.granted java code ...
... null) { throw new IllegalStateException("RealRxPermission.onRequestPermissionsResult invoked but didn't find the corresponding permission request.
Read more >
Android Runtime Permissions Example - DigitalOcean
Example : Let's say we want to access the camera and location in our app. Both are dangerous permissions. We'll display a prompt...
Read more >
How to Request Permissions in Android Application?
Step 4: Override onRequestPermissionsResult() method: onRequestPermissionsResult() is called when user grant or decline the permission.
Read more >
Confluence- java.lang.IllegalStateException: Sprin...
xml file and start confluence. Error Encountered Initially: HTTP Status 500 - java.lang.IllegalStateException: Spring Application context has ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found