With ADB how to open a given app on a given display?
Aug 30, 11:03pm
To open a specific app on a specific display using ADB (Android Debug Bridge), you can use a combination of ADB commands to achieve this. Here's a step-by-step guide:
1. Identify the App Package Name
First, you need the package name of the app you want to open. You can find it using:
bash
adb shell pm list packages | grep "app_name"
Replace "app_name" with a keyword related to the app (e.g., "chrome" for Google Chrome).
Alternatively, if you already know the app, you can list all installed packages:
bash
adb shell pm list packages
2. Identify the Display ID
To target a specific display, you need its display ID. List all connected displays:
bash
adb shell dumpsys display
Look for the HDR10DisplayManager or DisplayManager section to find the display IDs (e.g., HDR10DisplayManager: mDisplays=[0, 1]).
3. Launch the App on the Specified Display
Use the am start command with the --display flag to launch the app on the desired display:
bash
adb shell am start -n <package_name>/<activity_name> --display <display_id>
Replace <package_name> with the app's package name (e.g., com.android.chrome).
Replace <activity_name> with the main activity of the app (e.g., com.google.android.apps.chrome.Main).
Replace <display_id> with the target display ID (e.g., 1).
Example:
To open Google Chrome on display 1:
bash
adb shell am start -n com.android.chrome/com.google.android.apps.chrome.Main --display 1
4. Verify the App Launched on the Correct Display
Check the display's content or use:
bash
adb shell dumpsys window | grep "mCurrentFocus"
This will show the currently focused window and its display.
Notes:
Permissions: Ensure USB debugging is enabled on the device, and ADB is authorized.
Activity Name: If you don't know the activity name, use: