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.

Crash when denying run-time permission for location access in NearbyActivity

See original GitHub issue

I am encountering the following crash when I deny the run-time permission for location access when I hit the NearbyActivity

java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=1, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {fr.free.nrw.commons/fr.free.nrw.commons.nearby.NearbyActivity}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.app.ActivityThread.deliverResults(ActivityThread.java:3699) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742) at android.app.ActivityThread.-wrap16(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1842) at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1860) at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:650) at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:609) at fr.free.nrw.commons.nearby.NearbyActivity.onRequestPermissionsResult(NearbyActivity.java:167) at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:6553) at android.app.Activity.dispatchActivityResult(Activity.java:6432) at android.app.ActivityThread.deliverResults(ActivityThread.java:3695) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742)  at android.app.ActivityThread.-wrap16(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

This is cause the app is trying to load the NoPermissionsFragment in the onRequestPermissionsResult, which I think should be fine but clearly its not cause it crashes every time.

Secondly, launching a Fragment just to show a simple error message seems way too excessive. Personally, I would just show a dialog with the necessary error message along with 2 buttons, 1 with an “OK” text, clicking which would just close the activity and the other with a “Retry” text that would ask the run time permission again.

What do you guys think?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:17 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
Bluesir9commented, Sep 4, 2017

Of course. If we are decided on the Dialog route as a fix, then I could take this up. Will be a quick one anyways.

0reactions
Bluesir9commented, Jun 3, 2018

@TGar21 The stacktraces of the 2 crashes look different. The crash you encountered is caused because of calling “getLatitude” on a null “Location” object. So yeah, creating a new issue was the right thing to do.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Crash after granting permission. · Issue #1581 - GitHub
TGar21 mentioned this issue on Jun 2, 2018. Crash when denying run-time permission for location access in NearbyActivity #861.
Read more >
App crashes on disabling location permission from settings
You are getting an error regarding location access permission denied by the user and you need to check the permission granted by using ......
Read more >
Request location permissions - Android Developers
Types of location access. Foreground location; Background location; Accuracy. Request location access at runtime. User can grant only approximate location ...
Read more >
Choose which apps use your Android phone's location
On your phone's home screen, find the app icon. · Touch and hold the app icon. · Tap App info . · Tap...
Read more >
Apps is restarting when background location permission is ...
I'm expecting a denied callback in this result rather than an app restarting. ... called with a mode inconsistent with runtime permission state, ......
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