截取屏幕截图(带根)

时间:2013-07-20 14:15:13

标签: android screenshot android-2.3-gingerbread android-screen

所以我有这个代码截取到root设备上的任何屏幕截图,但似乎不起作用! 我的设备有2.3.7安卓版,我不知道我是否可以在这个术语中使用screencap。 如果我可以使用它,我是否必须下载任何c或cpp文件?

Process sh = Runtime.getRuntime().exec("su", null,null);
OutputStream  os = sh.getOutputStream();
os.write(("/system/bin/screencap -p " + Environment.getExternalStorageDirectory()+ "/img.png").getBytes("ASCII"));
os.flush();
os.close();
sh.waitFor()

我仍然添加了这个检查目录代码来检查屏幕截图是否被删除:

File f = new File(Environment.getExternalStorageDirectory()+ "/img.png");
            if(f.isDirectory() && f.isDirectory()) {
                Toast.makeText(getApplicationContext(), "Screenshot taked", 0).show();
            }else{
                Toast.makeText(getApplicationContext(), "Screenshot not taked", 0).show();
            }

1 个答案:

答案 0 :(得分:0)

使用root explorer,我访问了System/bin目录,文件screencap不存在,所以我认为这个android版本不支持screencap(2.3.7)

相关问题