How to check if the current activity has a dialog in front?

后端 未结 8 2059
自闭症患者
自闭症患者 2021-02-05 09:37

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 con

8条回答
  •  不要未来只要你来
    2021-02-05 10:14

    You can override activity method onWindowFocusChanged(boolean hasFocus) and track the state of your activity.

    Normally, if some alert dialog is shown above your activity, the activity does not get onPause() and onResume() events. But it loses focus on alert dialog shown and gains it when it dismisses.

提交回复
热议问题