adb shell screencap – Command to capture screenshot Android

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.

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”

Follow Lynxbee

Leave a Reply / Ask Question