adb command: View currently open applications

You can use the ADB (Android Debug Bridge) command to view currently open applications. Here are the steps on how to do this:

1. Connect your Android device or emulator to your computer and make sure ADB is started.

2. Open a terminal or command prompt window.

3. Run the following command in a terminal or command prompt to list currently open applications:

```shell

adb shell dumpsys activity activities | grep mResumedActivity

```

This command will return output similar to the following:

```
  ActivityRecord{560fed u0 com.hihonor.deskclock/com.android.deskclock.AlarmsMainActivity t1422}
``` 

In the output, you can see the "mResumedActivity" line, which contains the package name and activity name of the currently open application.

- In the above example, the package name is "com.hihonor.deskclock",

The activity name is "com.android.deskclock.AlarmsMainActivity".

In this way, you can use ADB commands to view the package name and activity name of the currently open application, that is, the application currently displayed on the screen. This is useful for monitoring application switching on your device.

Guess you like

Origin blog.csdn.net/m0_56687854/article/details/132451670