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

后端 未结 8 1877
自闭症患者
自闭症患者 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:15

    AFAIK - there is no public API for this.

    Recommended way is to have a reference to the dialog, and check for isShowing() and call dismiss() if necessary, but since you're using a third party library, this may not be an options for you.

    Your best bet is to check the documentation for the library you use. If that doesn't help, you're out of luck.

    Hint: Activity switches to 'paused' state if a dialog pops up. You may be able to 'abuse' this behavior ;)

提交回复
热议问题