I launch my dialog fragment using
FragmentTransaction ft =
getFragmentManager().beginTransaction();
MyDialogFragment dialog = new MyDialogFragment()
dialog.show(ft, "dialog");
then to get a handle on it I do
Fragment prev = getFragmentManager().findFragmentByTag("dialog");
but once I get prev
, how do I check if it is showing?
Back Story
My problem is that my looping code keeps launching the dialog again and again. But if the dialog is already showing, I don't want it to launch again. This back story is just for context. The answer I seek is not: "move it out of the loop."
if (dialogFragment != null
&& dialogFragment.getDialog() != null
&& dialogFragment.getDialog().isShowing()
&& !dialogFragment.isRemoving()) {
//dialog is showing so do something
} else {
//dialog is not showing
}