pietrorampini / UpdateChecker

Increase your app's updates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IllegalStateException: Can not perform this action after onSaveInstanceState

bjorncs opened this issue · comments

The looks like the Dialog class does not play well with its parent activity's life-cycle. I got following crash when the UpdateChecker tried to open a dialog in an activity that was already closed:

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1343)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1361)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:574)
at android.support.v4.app.DialogFragment.show(DialogFragment.java:127)
at com.rampo.updatechecker.UpdateChecker.showDialog(UpdateChecker.java:299)  

Fixed. 21c032a
Going to merge soon.

Your patch is not working correctly. You are catching on NullPointerException, while the exception you want to catch is a IllegalStateException.

Did you tried?
Personally I've tested it and works great, because the NullPointerException catch the cases when getActivity() returns null, as when the app it's already closed. I didn't spotted the bug again whit this fix.

Yes, I still get bug reports on this one. Look at the stack trace on first post. It is a IllegalStateException.

Does it works? @bjorncs

I haven't been able to get it tested out live yet. Anyway, I propose we just close this issue, as this fix should obviously work.