Posted on Leave a comment

Android close system dialog

Using Espresso and UiAutomator

action_close_system_dialog

Android task manager or system dialog

Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        Log.e("Focus debug", "Focus changed !");
        if (!hasFocus) {
            Log.e("Focus debug", "Lost focus !");
            Intent closeDialog = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
            sendBroadcast(closeDialog);
        }
}

How to dismiss system dialog in Android?

How do I use Espresso with System dialogs

Espresso can’t do it. We should use UiAutomator

InstrumentationRegistry.getInstrumentation().getUiAutomation().performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);

UiAutomator and Watchers: Adding Async Robustness to UI Automation

Handling Android runtime permissions in UI tests

How would Android UiAutomator behave if it encounters “Force Close or ANR”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.