Skip to content

Instantly share code, notes, and snippets.

@jp1017
Forked from 109021017/current_activity.sh
Created July 27, 2017 06:03
Show Gist options
  • Save jp1017/69c4d8720382c64a6e4a5ba284c32fb0 to your computer and use it in GitHub Desktop.
Save jp1017/69c4d8720382c64a6e4a5ba284c32fb0 to your computer and use it in GitHub Desktop.
A shell script log the current android top activity
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