Android / Kotlin Enthusiast 🤖

Shell Script to Take a Screenshot of Android Devices

Here is a Shell Script to take a screenshot of Android devices. You need setup adb before running this script. The script temporary saves the screenshot to device’s local /sdcard/, then move the file to current directory. The format of image is PNG, and the file name is {timestamp}.png.

filename=`date "+%s"`
adb shell screencap -p /sdcard/${filename}.png
adb pull /sdcard/${filename}.png
adb shell rm /sdcard/${filename}.png

The adb option of -p at the second line is for taking a screen shot with PNG format, but the document does not put the option, so maybe it is not required :)

Save the script asscreenshot.sh and run.

% sh screenshot.sh



  1. Android Debug Bridge (adb)  |  Android Developers (Last access: 2021/06/15)

#Android #Shell Script

About me 😎



Jetpack ComposeによるAndroid MVVMアーキテクチャ入門の著者です。

👉 もっと詳しく

Writing 📝

Android MVVMアーキテクチャ入門


👉 もっと詳しく

See Also 👀