Launch an app
android_launchLaunch an installed app's launcher activity on a connected Android device, optionally force-stopping it first for a cold start.
Instructions
Start an installed app's launcher activity, optionally force-stopping it first.
Args:
package_name (string, optional): application id, e.g. "com.example.myapp"
project_path (string, optional): Gradle root; the package is resolved from it when package_name is omitted
module (string): module to read the package from (default: 'app')
serial (string, optional): target device
force_stop (boolean): kill the app before starting, guaranteeing a cold start (default: false)
Returns: { "launched": boolean, "packageName": string, "serial": string }
Examples:
Use when: bringing an app to the foreground before taking a screenshot
Use when: you need a cold start to reproduce a launch-time bug -> force_stop=true
Don't use when: the app is not installed yet (use android_install)
Error Handling:
Reports when the package is not installed, rather than silently doing nothing
An app with no launcher activity cannot be started this way
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| module | No | Gradle module that produces the APK. Almost always 'app'. | app |
| serial | No | Device serial from android_list_devices. Optional when exactly one device is connected; required when several are. | |
| force_stop | No | Force-stop the app first so the next start is cold. | |
| package_name | No | Application id to launch. | |
| project_path | No | Gradle root to resolve the package from. |