通过adb命令查看当前运行Activity

一、说明

我们在做调试的时候有时候需要知道当前交互的 Activity 是哪个。当然,如果是你自己的项目的话你肯定特别熟悉所处页面,如果在新的项目下,对项目还不是很熟悉时,你就需要快速定位到你所在的页面,然后再去修改这个页面的代码。

二、输入命令

adb shell dumpsys activity | grep -i run

三、输出信息

service_reset_run_duration=60000
  * ContentProviderRecord{77160a5 u0 com.com.zg/com.android.tools.fd.runtime.InstantRunContentProvider}
    authority=com.zg.sample.com.android.tools.fd.runtime.InstantRunContentProvider
    Running activities (most recent first):
        Run #2: ActivityRecord{7af5723 u0 com.zg.sample/.activity.LiveRecordPlayActivity t321}
        Run #1: ActivityRecord{f1d95c0 u0 com.zg.sample/.activity.LiveRecordActivity t321}
        Run #0: ActivityRecord{3ceec2e u0 com.zg.sample.activity.MainActivity t321}
    Running activities (most recent first):
        Run #0: ActivityRecord{c4c62e u0 com.huawei.android.launcher/.unihome.UniHomeLauncher t230}
ACTIVITY MANAGER RUNNING PROCESSES (dumpsys activity processes)
    User #0: state=RUNNING_UNLOCKED

而你只需要关注以下信息:

Running activities (most recent first):
        Run #2: ActivityRecord{7af5723 u0 com.zg.sample/.activity.LiveRecordPlayActivity t321}
        Run #1: ActivityRecord{f1d95c0 u0 com.zg.sample/.activity.LiveRecordActivity t321}
        Run #0: ActivityRecord{3ceec2e u0 com.zg.sample.activity.MainActivity t321}

输出信息说得很清楚,列出的是你打开的所有页面,而顺序是以最近打开为先。

 

搞定!

 

你可能感兴趣的:(Android-技术篇)