Using ADB to capture the screen
You can read the binary from stdout instead of saving the png to the sdcard and then pulling it: This should save a little time, but not much. source: Read binary stdout data from adb shell?
Technical answers from my Stack Overflow history, with source links and licenses.
Showing 17 of 17 answers tagged adb
Exported May 9, 2026
You can read the binary from stdout instead of saving the png to the sdcard and then pulling it: This should save a little time, but not much. source: Read binary stdout data from adb shell?
This worked for me: com.facebook.katana Updated answer for Android Q as mCurrentFocus was no longer working for me:
Is there an equivalent command for retrieving Advertising Id? There is no equivalent command but it is possible if you use grep . The following command works on rooted devices
You can use toybox find : Toybox is included with Android 6.0 (Marshmallow) and all later Android versions.
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...
Alex has a great answer. WARNING : Ugly code ahead I was able to get the signature in adb shell as root with the following code: indented:
Using adb shell pm grant [PACKAGE_NAME] android.permission.PACKAGE_USAGE_STATS worked for me on several devices. Make sure you added the following to the AndroidManifest : I was also able to use root to grant the...
You can use an unconditional loop: You can also look into tools like inotifywait or fsmon depending on what you are trying to accomplish. You can also install busybox for Android which contains the watch command.
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...
Running this from the command-line worked for me: If it returns 0 or 2 the device is in portrait. If it returns 1 or 3 the device is in landscape. Note: I am on a rooted device and have busybox with grep , awk , and...
You need root access to do this. It would be a huge security issue otherwise. You can use a library like libsuperuser to run root commands. Example using libsuperuser:
This was a problem with ADB. ADB use to verify that the file was an APK and read the entire file into memory before installation. This could cause mallac to return NULL , closing your ADB session (see file_sync_client.c...
Just because the app name is "2048" does not mean it is used in the package name. However, I looked up the most popular Google Play game and it does have 2048 in the package name. You could use grep to get the package....
You will need root access to do this from an app because ADB can access /system/bin/service but your app cannot (see GID of app and ADB). You should also check out third party libraries for handling su commands:...
You will not be able to use the pm command with your application UID; you need to be root (0) or shell (2000). This may be why you are getting a permission denied error. I successfully set the installer package name...
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: