With `adb` how to start a given app on a given display?
Apr 4, 11:13pm

To start a specific Android app on a given display using adb, you can use the am start command with the --display option. Here’s how you can do it:

Prerequisites

  • Ensure USB debugging is enabled on your Android device.
  • Connect your device to your computer and authorize the connection.
  • Know the package name and activity name of the app you want to start.

Command Syntax

shell
adb shell am start --display <DISPLAY_ID> -n <PACKAGE_NAME>/<ACTIVITY_NAME>

Parameters:

<DISPLAY_ID>
The ID of the display (e.g., 1 for the main display, 2 for a secondary display).
<PACKAGE_NAME>
The package name of the app (e.g., com.example.app).
<ACTIVITY_NAME>
The activity name to launch (e.g., .MainActivity).

Example

Suppose you want to start the app with package name com.example.myapp and activity com.example.myapp.MainActivity on display 2:

shell
adb shell am start --display 2 -n com.example.myapp/com.example.myapp.MainActivity

How to Find Display IDs

To list available displays, use:

shell
adb shell dumpsys display

Look for the mDisplayId field in the output.


Notes

  • If the app is already running, this command will bring it to the foreground on the specified display.
  • If the display ID is not specified, the app will start on the default display.
Apr 4, 11:13pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.