Showing a DialogFragment throws Can not perform this action after onSaveInstanceState error
Since dialogfragment does not have option to commitAllowingStateLoss
, the simplest solution I used was to set a flag when onSaveInstance is called and reset it on onCreate
and onRestoreInstance
. Then before making a fragment transaction, check the flag to be sure its false. btw, this usually occurs in a asynchronous callback. The activity is already gone beyond onSaveInstance by the time background work has completed and callback has triggered.
Showing dialog fragment throws can not perform this action after onSaveInstanceState exception
As I discovered the problem was caused by Android issue, I had the following workaround solution: just override show() method of the dialog fragment as it is below:
@Override
public void show(@NonNull FragmentManager manager, @Nullable String tag) {
FragmentTransaction ft = manager.beginTransaction();
ft.add(this, tag);
ft.commitAllowingStateLoss();
}
Related Topics
Where Is the All Android Broadcast Intent List
Android Opengl .Obj File Loader
What Is the Meaning of Android.Intent.Action.Main
Cannot Find Zip-Align When Publishing App
How to Display Both Icon and Title of Action Inside Actionbar
Android 4.0, Text on the Action Bar Never Shows
API to Automatically Upload APK to Google Play
Finding the Dominant Color of an Image in an Android @Drawable
Android Multiple Screen Sizes with Same Density
How to Programmatically Log Out from Facebook Sdk 3.0 Without Using Facebook Login/Logout Button
Android Screen Sizes in Pixels for Ldpi, Mdpi, Hpdi
Load Image from Url in Notification Android
Live Character Count for Edittext
Loading All the Images from Gallery into the Application in Android
Android Studio Where to Install Ndk File? (Downloaded It in Zip)