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
func (d *Device) Hook(ctx context.Context, name string, args ...string) (any, error)
Hook calls a hook the app registered with Mobium's gray-box library, by name, and returns what it answered, decoded from JSON — 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 is an ErrInvalidArgument naming the ones it did.
Examples
Call a hook the app registered, and get back what it answered
if err := dev.LaunchWithGrayBox(ctx, "dev.mobium.mobiumapp"); err != nil {
return err
}
answer, err := dev.Hook(ctx, "raiseToast", "Toast raised by test script")
if err != nil {
return err
}
fmt.Println(answer) // 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