adb shell screencap – Use ADB to capture the Screen

If you want to take video of screen, refer post “How to Record Screen Video in android using adb ?”

If you want to take screen capture of something happening on your phone screen and save it as image to be sent to someone or own reference for analysis, Android provides an utility/command “screencap” using which which can save screen to image.

“screencap” command can be used as below to take screenshot and save as image,

$ adb shell screencap /sdcard/my_screenshot.png

Above command saves png image of screenshot in your device/mobile’s /sdcard folder, which we need to download for viewing, use below adb pull command to download to local machine,


Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )

   


$ adb pull /sdcard/my_screenshot.png
/sdcard/my_screenshot.png: 1 file pulled. 11.3 MB/s (1316280 bytes in 0.111s)

Now, you have the image on your local PC, you can open it from command line using command eog as,

$ eog my_screenshot.png

The other command line options supported by screencap command are as below,

usage: screencap [-hp] [-d display-id] [FILENAME]
   -h: this message
   -p: save the file as a png.
   -d: specify the display id to capture, default 0.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.

If you want to prevent others to take screenshot of your application, check our another post, “How to prevent Screenshot / Screen Capture in Android JAVA & Kotlin”

lynxbee_ezoic

Leave a Comment

Android Android Build system Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded