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.

Can't perform this action after onSaveInstanceState

See original GitHub issue
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
        at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1689)
        at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1729)
        at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:321)
        at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:286)
        at com.emaar.shopndrop.navigation.MultiStackNavigator.showInternal(MultiStackNavigator.kt:320)
        at com.emaar.shopndrop.navigation.MultiStackNavigator.show(MultiStackNavigator.kt:119)
        at com.emaar.shopndrop.activities.MainActivity$fetchRequestDetail$1.onNext(MainActivity.kt:193)
        at com.emaar.shopndrop.activities.MainActivity$fetchRequestDetail$1.onNext(MainActivity.kt:178)
        at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:201)
        at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255)
        at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

@tunjid I’m getting this error. What I’m trying is after launching MainActivity hitting the web API and launching fragment.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
guyaumetremblaycommented, Jan 4, 2021

@tunjid I just found this: https://stackoverflow.com/a/10261449

I do have a onSaveInstanceState which add something in the outState after calling super. As I understand the accepted answer on the SO thread, the exception is happening because MultiStackNavigator is calling fragmentManager.commit instead of commitAllowingStateLoss.

We’ll try to fix our onSaveInstanceState as I don’t think changing from commit to commitAllowingStateLoss on your side is a proper solution!

1reaction
chnoumancommented, Jan 4, 2021

@guyaumetremblay sorry buddy I can’t remember what exactly was the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling IllegalStateException: Can not perform this action ...
When the user change the Location Setting, it will then trigger the call of onResume() again, even after onSaveInstanceState() is called. Hence this...
Read more >
Can not perform this action after onSaveInstanceState with ...
Basically I just had to : @Override protected void onSaveInstanceState(Bundle outState) { //No call for super(). Bug on API Level > 11. }...
Read more >
IllegalStateException : Cannot perform this action after ...
The main root cause of this exception is that fragment transactions are not allowed after the OnSaveInstanceState of the activity is called.
Read more >
IllegalStateException: Can not perform this action after ...
Cause of the problem: after call of onSaveInstanceState fragment manager cannot apply any transactions. Possible solution: call cleanUp method ...
Read more >
Bug: "IllegalStateException: Can not perform this action after ...
I am getting the same error. The way I am reproducing is to hold my thumb on a menu button and with another...
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