android程序执行adb shell命令
2017-11-04 17:13
337 查看
文章转载自:http://blog.csdn.net/buptgshengod
备注:要操作data/下面的要保证有root权限和读写权限
可以用下面方法检测是否有root权限
如果在PhoneWindowManager.java中写则不需要管权限,他的权限比较高
final String FILE_NAME = "cat data/misc/wifi/wpa_supplicant.conf";
if(DEBUG) Log.d("chenshichun"," "+this.getClass().getCanonicalName()+" ::::::::: exec(FILE_NAME)::"+ exec(FILE_NAME));
private String exec(String command) { try { Process process = Runtime.getRuntime().exec(command); BufferedReader reader = new BufferedReader( new InputStreamReader(process.getInputStream())); int read; char[] buffer = new char[4096]; StringBuffer output = new StringBuffer(); while ((read = reader.read(buffer)) > 0) { output.append(buffer, 0, read); } reader.close(); process.waitFor(); return output.toString(); } catch (IOException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } }
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
备注:要操作data/下面的要保证有root权限和读写权限
chmod 777 /data/misc/wifi/wpa_supplicant.conf
可以用下面方法检测是否有root权限
RootTools.isRootAvailable()
如果在PhoneWindowManager.java中写则不需要管权限,他的权限比较高
相关文章推荐
- 【android-tips】android程序执行adb shell命令(实例源码)
- Android 程序执行Linux命令的解决方法及注意事项
- Android Java代码执行adb Shell命令
- Android Java代码执行adb Shell命令
- android ADB shell 命令启动 android程序
- android不是内部或外部命令,也不是可执行的程序或批处理文件
- android apk 怎么执行adb shell命令
- Android调用另一个现成的可执行程序或系统命令
- 怎么在Android程序中执行Linux shell 命令
- Android Java代码执行adb Shell命令
- 自己写android java 小程序 执行sh命令
- 同步执行其他程序(dos命令)
- android adb shell 命令之uname
- Android 开发手记二 C可执行程序编译实例(转帖)
- android真机调试时使用adb shell命令 windows
- Ubuntu中为Android系统上实现内置C可执行程序测试Linux内核驱动程序
- Android系统Recovery工作原理之使用update.zip升级过程分析(八)---升级程序update_binary的执行过程
- Android adb和adb shell命令
- Java 在windows上操作系统文件与程序,执行系统命令等的技巧
- Redis学习笔记3-Redis5个可执行程序命令的使用