Skip to content

Instantly share code, notes, and snippets.

@Guang1234567
Forked from 109021017/current_activity.sh
Last active March 11, 2024 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Guang1234567/46b243a3de35813ae311c42e5c060ad4 to your computer and use it in GitHub Desktop.
Save Guang1234567/46b243a3de35813ae311c42e5c060ad4 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 | 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 | grep -E 'mCurrentFocus')
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment