How to Capture Screenshot in android using adb ?

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,

 $ 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.

Android Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense Multimedia - Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question