codekidX / storage-chooser

Lets user choose files in internal or external storage with just few lines of code.
Mozilla Public License 2.0
721 stars 153 forks source link

[BUG] Frequent IlegalStateExceptions #125

Closed vidicunt closed 3 years ago

vidicunt commented 4 years ago

I'm frequently getting IllegalStateException errors on my Firebase Crashlytics report. I'm not sure if my implementation is faulty or not.

Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.app.FragmentManagerImpl.checkStateLoss(FragmentManagerImpl.java:1881) at android.app.FragmentManagerImpl.enqueueAction(FragmentManagerImpl.java:1904) at android.app.BackStackRecord.commitInternal(BackStackRecord.java:688) at android.app.BackStackRecord.commit(BackStackRecord.java:646) at android.app.DialogFragment.show(DialogFragment.java:238) at com.codekidlabs.storagechooser.StorageChooser.init(StorageChooser.java:15) at com.ripelimeapps.android.mediadownloader.home.post.PostFragment.saveFileTo(PostFragment.java:22) at com.ripelimeapps.android.mediadownloader.home.post.PostFragment$permissionRequestResultBroadcast$1.onReceive(PostFragment.java:27) at androidx.localbroadcastmanager.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:1) at androidx.localbroadcastmanager.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:1) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:216) at android.app.ActivityThread.main(ActivityThread.java:7266) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

codekidX commented 4 years ago

This looks like fragment not maintaining state on rotation, though I'm not sure. Did you check out the notes and added the configChanges element in manifest file?

vidicunt commented 4 years ago

True, I did not add that line to my manifest. Would it be possible to have a version without the configChanges in the future? I believe it's best practice, in my case at least for android to handle the configuration changes.

Thank you!