How to know which is the active page of the current screen from the log of logcat?

logcat | grep -E "ActivityTaskManager: START|Displayed"

In the Android system, logcatthe system log can be obtained through commands, and then the active page on the current screen can be found. To logcatget the current activity from the log, follow these steps:

  1. First, connect your Android device and make sure the device is in debug mode.

  2. Open a Command Prompt (Windows) or Terminal (macOS/Linux), and run the following command to get filtered output logcat:

    adb logcat ActivityManager:I *:S

    This command will display all information related to Activity Manager and block other irrelevant logs.

  3. Perform actions on the device, such as opening an app or switching activities. In a command prompt or terminal, you will see log output similar to the following:

    I/ActivityManager( 1234): Displayed com.example.app/.MainActivity: +1s000ms

In this example, the Activity currently on the screen is com.example.app/.MainActivity.

Note that this method may not work on all Android versions, as the log output format may vary from version to version. However, it generally works for most situations.

Guess you like

Origin blog.csdn.net/kill150/article/details/130203211