Skip to content

Instantly share code, notes, and snippets.

@109021017
109021017 / current_activity.sh
Created February 3, 2016 09:32
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