2014-01-08 28 views
0

我试图从我的Android应用程序执行shell脚本以获取当前屏幕视图。 我有下面的代码只能在根目录的设备上正常工作。为当前屏幕运行shell命令(“su”)查看

Process sh = null; 
    try 
    { 
     Thread thread=new Thread(new Threadcalling()); 
     thread.start(); 

     sh = Runtime.getRuntime().exec("su"); 
     OutputStream os = sh.getOutputStream(); 
     os.write(("/system/bin/screencap -p " + "/sdcard/img.png").getBytes("ASCII")); 
     os.flush(); 
     os.close(); 
     sh.waitFor(); 
    } 
    catch (Exception e){} 

我应该做些什么修改才能在无根设备上获取屏幕视图。

任何帮助将不胜感激。谢谢。

+0

你不能这样做,在无根的设备。如果你能够写出邪恶的间谍软件。 – zapl

回答