Android 系统自带截屏命令 screencap,其可执行文件位于:/system/bin/,源码位于:frameworks/base/cmds/screencap。
查看帮助
可以使用screencap -h命令查看帮助信息。
D:\log>adb shell screencap -husage: screencap [-hp] [-d display-id] [FILENAME]-h: this message-p: save the file as a png.-d: specify the physical display ID to capture (default: 59)see "dumpsys SurfaceFlinger --display-id" for valid display IDs.If FILENAME ends with .png it will be saved as a png.If FILENAME is not given, the results will be printed to stdout.
解释
用法: screencap [-hp] [-d 显示id] [文件名]
-h: 查看帮助信息
-p: 保存文件为png格式
-d: 指定截取的显示id,默认为fb0(fb为framebuffer)
如果文件名以.png结束,将保存为png格式文件
如果没有文件名,将直接打印到标准输出
使用说明
1.截取fb0界面到sdcard,并导入到电脑,可以进行查看。
adb shell screencap -p sdcard/fb0.png
adb pull /sdcard/fb0.png
adb shell rm /sdcard/fb0.png
2.截取fb1界面到sdcard,文件名为fb1.png
adb shell screencap -d /dev/graphics/fb1 sdcard/fb1.png