Android shell get foreground app package name
This worked for me: com.facebook.katana Updated answer for Android Q as mCurrentFocus was no longer working for me:
Technical answers from my Stack Overflow history, with source links and licenses.
Showing 8 of 8 answers tagged shell
Exported May 9, 2026
This worked for me: com.facebook.katana Updated answer for Android Q as mCurrentFocus was no longer working for me:
I created the following shell script name it pullsharedprefs.sh (or whatever you want) and from terminal run the command: shared_prefs will be pulled to the current working directory and named...
You can only execute /system/bin/input as the root or shell user; this will not work in an app. The command should not start with "adb shell" when running from the app. To run the command as root: You should also check...
You need to get the redirect from bit.ly and then download all files. This is real ugly, but it worked: If you use the direct link, this will work:
You can use a case statement to get the density. This worked for me: Updated code using -le (less than or equal to): Output on my device:
You can use toybox find : Toybox is included with Android 6.0 (Marshmallow) and all later Android versions.