user12394138
user12394138

Reputation: 31

Unable To get Activity name from adb command Android 10

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.

Upvotes: 3

Views: 4059

Answers (4)

Rayman
Rayman

Reputation: 151

adb shell dumpsys window | grep "mCur"

That you can find the first window you're interacting, maybe is an activity

Upvotes: 0

G.Zxuan
G.Zxuan

Reputation: 86

adb shell dumpsys activity activities | grep "mFocused"

It worked on android 10 & 11.

Upvotes: 1

BYN13K
BYN13K

Reputation: 47

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}

Upvotes: 1

John
John

Reputation: 1337

adb shell dumpsys activity a . | grep -E 'mResumedActivity' | cut -d ' ' -f 8

Upvotes: 2

Related Questions