How to check if a dialog is open

I have an app with a fragment that runs every 5 seconds and do an API call to check for updates, if it detects an update, it’ll rerun the app. The problem is that I also have some forms in my app using dialogs. If the fragment detects an update when the user is using a dialog, the app will rerun, closing the dialog.

Because of that, I need the fragment to check if a dialog is open before running the app again.

There isn’t a native way to detect the state of the dialog. However, there are some related feature requests you might be interested in upvoting: