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​

hook(name: string, ...args: string[]): Promise<unknown>

Examples​

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

await device.launch('dev.mobium.mobiumapp', { grayBox: true })
console.log(await 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 &quot;Toast raised by test script&quot; on MobiumApp, Android 15 emulator, launched with --gray-box: the app&#39;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