I have a dialogfragment which displays fine but some time when I try to display it I keep getting IllegalStateException
Below is the logcat
Here my solution, I have try to click show dialog fragment by tap button multiple time and quickly.
try{
FragmentManager fm = getSupportFragmentManager();
Fragment oldFragment = fm.findFragmentByTag("wait_modal");
if(oldFragment != null && oldFragment.isAdded())
return;
if(oldFragment == null && !please_wait_modal.isAdded() && !please_wait_modal.isVisible()){
fm.executePendingTransactions();
please_wait_modal.show(fm,"wait_modal");
}
}catch (Exception e){
e.printStackTrace();
}
Fragment transactions are asynchronous.
It is possible that you have two or more calls to this code before the fragment transactions are executed. !selectPlan04Dialog.isVisible() & !selectPlan04Dialog.isAdded()
condition is true and show()
schedules another fragment transaction to execute later.
Some options for fixing this:
executePendingTransactions()