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​

public object? Hook(string name, params string[] args)

Calls a hook the app registered with Mobium's gray-box library, by name, and returns what it answered — sign in, seed data, raise a toast, without walking the UI. The app must have been launched with LaunchWithGrayBox. A name the app never registered throws an InvalidArgumentException naming the ones it did.

Examples​

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

device.LaunchWithGrayBox("dev.mobium.mobiumapp");
var answer = 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