Skip to content

Instantly share code, notes, and snippets.

@act262
Last active November 14, 2021 16:38
Show Gist options
  • Save act262/84d84b151387ae924bbc3087c5688065 to your computer and use it in GitHub Desktop.
Save act262/84d84b151387ae924bbc3087c5688065 to your computer and use it in GitHub Desktop.
Top current window&activity
oldActivity=""
displayName=""
currentActivity=`adb shell dumpsys activity | grep mFocusedActivity`
while true
do
if [[ $oldActivity != $currentActivity && $currentActivity != *"=null"* ]]; then
displayName=${currentActivity% *}
displayName=${displayName##* }
echo $displayName
oldActivity=$currentActivity
fi
currentActivity=`adb shell dumpsys activity | grep mFocusedActivity`
done
# shell:/ $ dumpsys activity | grep mFocusedActivity
# mFocusedActivity: ActivityRecord{426c48d0 u0 io.micro.adt/.ui.MainActivity t29}
oldActvity=""
displayName=""
currentActivity=`adb shell dumpsys window windows | grep -E 'mCurrentFocus'`
while true
do
if [[ $oldActvity != $currentActivity && $currentActivity != *"=null"* ]]; then
displayName=${currentActivity##* }
displayName=${displayName%%\}*}
echo $displayName
oldActvity=$currentActivity
fi
currentActivity=`adb shell dumpsys window windows | grep -E 'mCurrentFocus'`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment