Skip to main content

alert · answerAlert

This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET

Read a system dialog, or answer it with accept or dismiss. These call app_alert.

alert​

public String alert()

What a system dialog says, or an empty string when none is up.

A permission prompt is another process's window, not the app's, and reading it needs no knowledge of what the buttons say.

@return the dialog's text, or an empty string when none is up

answerAlert​

public void answerAlert(boolean accept)
public void answerAlert(boolean accept, String text)

Accepts or dismisses a system dialog.

These answer a dialog; they do not choose an outcome. On a permission prompt they do not mean grant and deny, and on iOS they are the other way round — accept leaves it denied and dismiss leaves it granted, because W3C accept presses the affirmative button and Apple puts "Don't Allow" last. Tap the button by ref for a particular answer.

@param accept true to accept, false to dismiss

Types into a dialog's field, then accepts or dismisses it, in one call. A plain alert has no field, and the platform refuses the text. What accept and dismiss press is as for answerAlert(boolean).

@param accept true to accept, false to dismiss @param text what to type into the prompt's field first

Examples​

Ask whether a system dialog is up, and what it says​

String says = device.alert(); // "" when no dialog is up
if (!says.isEmpty()) System.out.println(says);

The same call from the command line, mobium alert, printed on an Android 15 emulator:

a dialog is on screen: "Discard changes?\nThey will be lost."

mobium alert on an Android 15 emulator

mobium alert on an Android 15 emulator

Answer it with the platform's accept button​

device.answerAlert(true);

The same call from the command line, mobium alert accept, printed on an Android 15 emulator:

accepted the dialog "Discard changes?\nThey will be lost." — this answered it and did not choose an outcome: on a permission prompt accept and dismiss do not mean grant and deny, and on iOS they are the other way round. Tap the button by ref if you need a particular answer
BeforeAfter
Before: mobium alert accept on an Android 15 emulatorAfter: mobium alert accept on an Android 15 emulator

mobium alert accept on an Android 15 emulator

More examples​

Fill a prompt's field and accept it, in one call​

device.answerAlert(true, "Groceries");