3

I'm trying to get activity name for current focused app on the device by running this command:

adb shell "dumpsys window windows | grep -E 'mCurrentFocusApp|mFocusedApp'"

It works on older phone with Android 6.0 but on Pixel XL running Android 10 its returns nothing.

If I run only dumpsys window windows it returns bunch of unfiltered info which is not very efficient for me.

B--rian
  • 5,578
  • 10
  • 38
  • 89
user12394138
  • 31
  • 1
  • 2

3 Answers3

2
adb shell dumpsys activity a . | grep -E 'mResumedActivity' | cut -d ' ' -f 8
John
  • 1,139
  • 3
  • 16
  • 33
1

John answer is great but u can use:

adb shell dumpsys window windows | grep mActivityRecord

in that case u get list of all current run app in memory if u kill all app and run the one u want u get 2 records

# launcher 
mActivityRecord=ActivityRecord{99197dc u0 com.sec.android.app.launcher/.activities.LauncherActivity t3161}
# active app
mActivityRecord=ActivityRecord{6dec4d5 u0 com.google.android.googlequicksearchbox/com.google.android.apps.gsa.monet.MonetActivity t3711}
BYN13K
  • 47
  • 1
  • 7
0
adb shell dumpsys activity activities | grep "mFocused"

It worked on android 10 & 11.

G.Zxuan
  • 66
  • 3