Skip to main content

hook

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

Call a hook the app registered with Mobium's gray-box library, by name, and return what it answered — sign in, seed data, raise a toast: state set up without walking the UI. These call app_hook.

hook​

def hook(name: str, *args: str, timeout_ms: int | None=None) -> Any

Call a hook the app registered with Mobium's gray-box library, by name, and return what it answered — sign in, seed data, raise a toast, without walking the UI. The app must have been launched with launch(app, gray_box=True). Raises InvalidArgumentError for a name the app never registered, naming the ones it did.

Examples​

Call a hook the app registered, and get back what it answered​

device.launch("dev.mobium.mobiumapp", gray_box=True)
print(device.hook("raiseToast", "Toast raised by test script")) # shown

The same call from the command line, mobium hook raiseToast "Toast raised by test script", printed on an Android 15 emulator:

hook raiseToast answered: "shown"
gray box: the app was idle

mobium hook raiseToast "Toast raised by test script" on MobiumApp, Android 15 emulator, launched with --gray-box: the app's own toast says what the hook was sent

mobium hook raiseToast "Toast raised by test script" on MobiumApp, Android 15 emulator, launched with --gray-box: the app's own toast says what the hook was sent