2013-07-20 131 views
3

所以我有这段代码可以在根源设备上的任何屏幕截图,但似乎没有工作! 我的设备有2.3.7 android版本,我不知道在这方面我可以使用screencap。 如果我可以使用它,我必须下载任何c或cpp文件吗?拍摄屏幕截图(含root)

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(); 
      } 

回答

0

有了根探险家,我去System/bin目录,文件screencap是不存在的,所以我想那个screencap不支持这个android版本(2.3.7)