'dumpsys window windows | grep -E 'mCurrentFocus' command is not giving me any result

I am giving dumpsys window windows | grep -E 'mCurrentFocus | mFocusedApp' command in the command prompt and it is not giving any results.enter image description here



Solution 1:[1]

Remove the extra spaces:

dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'

Solution 2:[2]

On my Android 11 device, using dumpsys window windows doesn't give the currently focused window. Instead one has to do:

dumpsys window displays | grep -E 'mCurrentFocus|mFocusedApp'

I think a solution that works on all devices is:

dumpsys window | grep -E 'mCurrentFocus|mFocusedApp'

(dumpsys window dumps information about all the subtopics, including windows and displays).

Solution 3:[3]

Use this code. dumpsys window | grep -E 'mCurrentFocus|mFocusedApp'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alex P.
Solution 2 Alexander Pruss
Solution 3 Ankit Sharma