Android 使用shell screencap / screenshot命令截屏
2014-10-14 00:00
141 查看
摘要: 你将了解如何通过shell命令进行截屏
在Android里可以通过使用shell命令来截屏,一般用于应用程序外截屏,需要root权限。
1)在PC上使用cmd命令截屏
或者
以上命令的意思是截取当前屏幕,以文件名123.png保存到sdcard目录下。
2)在Android应用里面截屏
要给AndroidManifest.xml加上权限
详细见:https://www.zybuluo.com/olunx/note/18021
在Android里可以通过使用shell命令来截屏,一般用于应用程序外截屏,需要root权限。
1)在PC上使用cmd命令截屏
adb shell screencap -p /sdcard/123.png
或者
adb shell screenshot /sdcard/123.png
以上命令的意思是截取当前屏幕,以文件名123.png保存到sdcard目录下。
2)在Android应用里面截屏
/** * * @param path 图片保存路径 */ public void screenshot(String path){ Process process = null; try{ process = Runtime.getRuntime().exec("su"); PrintStream outputStream = null; try { outputStream = new PrintStream(new BufferedOutputStream(process.getOutputStream(), 8192)); outputStream.println("screencap -p " + path); outputStream.flush(); }catch(Exception e){ e.printStackTrace(); } finally { if (outputStream != null) { outputStream.close(); } } process.waitFor(); }catch(Exception e){ e.printStackTrace(); }finally { if(process != null){ process.destroy(); } } }
要给AndroidManifest.xml加上权限
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
详细见:https://www.zybuluo.com/olunx/note/18021
相关文章推荐
- android 截图,视频录制命令 screencap screenrecord screenshot
- android makefile 文件中使用shell命令
- android-代码里使用shell命令(wifi调试)
- ubuntu 使用adb shell命令识别android设备
- Android 学习笔记---使用shell命令来关闭和开启ADB
- Android中使用代码执行shell命令
- android shell命令screenrecord和uptime,reboot
- Android 编程使用shell命令
- Android 使用adb shell命令时出现sqlite3 : not found 问题 解决方法
- Android 使用Shell脚本截屏并自动传到电脑上
- jni使用c语言调用android shell命令方法
- Android 4.2获取root权限后以后使用shell命令来开启飞行模式
- Android 使用adb shell命令时出现sqlite3 : not found 问题 解决方法
- 如何在android.mk中使用shell命令
- 在windows下使用cmd命令通过adb shell自动调用android模拟或真机的InstrumentRunner进行android 自动化测试
- 【转载】Using SQLite from Shell in Android(在shell 下使用sqlite命令操作数据库)
- Android使用adb命令对手机进行截屏保存到电脑&SDCard
- Android教程之Android SDK1.5模拟器使用命令
- screen命令使用介绍
- 在 PHP 中使用命令行工具 在 Web 应用程序中运行 shell 命令