有没有办法通过adb获取当前活动的详细信息?
发布于 2012-11-04 02:44:32
与dumpsys activity
相比,我更喜欢解析dumpsys window windows
的结果
adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'
键盘守卫或最近的任务列表过去不会显示为活动,但您可以使用mCurrentFocus
查看它们。我已经在this answer中解释了原因。
发布于 2019-10-17 02:25:31
Android Q为我破解了其中的大部分。这里有一个新的似乎正在工作(至少在Android Q上)。
adb shell "dumpsys activity activities | grep mResumedActivity"
输出如下所示:
mResumedActivity: ActivityRecord{7f6df99 u0 com.sample.app/.feature.SampleActivity t92}
编辑:我也能在Android R上工作
发布于 2015-03-11 02:35:48
dumpsys window windows
提供了有关当前活动的更多详细信息:
adb shell "dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'"
mCurrentFocus=Window{41d2c970 u0 com.android.launcher/com.android.launcher2.Launcher}
mFocusedApp=AppWindowToken{4203c170 token=Token{41b77280 ActivityRecord{41b77a28 u0 com.android.launcher/com.android.launcher2.Launcher t3}}}
但是,为了找到进程ID (例如,终止当前活动),可以在“top-activity”上使用dumpsys activity
和grep:
adb shell "dumpsys activity | grep top-activity"
Proc # 0: fore F/A/T trm: 0 3074:com.android.launcher/u0a8 (top-activity)
adb shell "kill 3074"
https://stackoverflow.com/questions/13193592
复制相似问题