How to check if the current activity has a dialog in front?
问题 I am using a third-party library and sometimes it pops up a dialog. Before I finish the current activity, I want to check whether there is a dialog popped up in the current context. Is there any API for this? 回答1: You can check it running over the active fragments of that activity and checking if one of them is DialogFragment, meaning that there's a active dialog on the screen: public static boolean hasOpenedDialogs(FragmentActivity activity) { List<Fragment> fragments = activity