Created
January 21, 2013 21:53
-
-
Save bootstraponline/4589830 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Implement is focused app using dumpsys window windows | |
def is_focused_app app | |
output = `#{adb_command} shell dumpsys window windows` | |
return false if output.nil? | |
target = nil | |
output.each_line do |line| | |
if line.include? 'mFocusedApp' | |
target = line | |
break | |
end | |
end | |
return false if target.nil? | |
focused = target.match(/\/\.([^}]+)}/) | |
return false if focused.nil? | |
focused[1] == app | |
end | |
puts is_focused_app 'MyActivity' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jonasmaturana I think your
focused_activity
is better. Then something like this can be written: