我正在通过运行此命令来获取设备上当前关注的应用程序的活动名称:
adb shell "dumpsys window windows | grep -E 'mCurrentFocusApp|mFocusedApp'"
[它可在装有Android 6.0的旧手机上使用,但在运行Android 10的Pixel XL上则不返回任何内容。
如果我仅运行dumpsys window windows
,它将返回一堆未经过滤的信息,这对我来说不是很有效。
adb shell dumpsys activity a . | grep -E 'mResumedActivity' | cut -d ' ' -f 8