tvbarthel / BlurDialogFragment

Library project to display DialogFragment with a blur effect.
Apache License 2.0
2.09k stars 334 forks source link

Getting IllegalStateException when trying to show fragment #88

Open hassanabidpk opened 7 years ago

hassanabidpk commented 7 years ago

I am getting the following exception when trying to show BlurDialogFragment more than 1 time in Activity.

  at android.app.FragmentManagerImpl.enqueueAction (FragmentManager.java:1431)
  at android.app.BackStackRecord.commitInternal (BackStackRecord.java:687)
  at android.app.BackStackRecord.commit (BackStackRecord.java:663)
  at android.app.DialogFragment.show (DialogFragment.java:230)
  at com.myapp.android.app.activities.HomeActivity$6.run (HomeActivity.java:589)
  at android.os.Handler.handleCallback (Handler.java:746)
  at android.os.Handler.dispatchMessage (Handler.java:95)
  at android.os.Looper.loop (Looper.java:148)
  at android.app.ActivityThread.main (ActivityThread.java:5443)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:728)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:618)

I have tried using following way to delay it by 1 msec, but still getting it.

new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                    fragment.show(getFragmentManager(), "report_survey_dialog");
            }
        }, 1000);

My guess is that it is happening when Activity is in background. Do you have solution or tip for handling this?