android程序执行adb shell命令
来源:互联网 发布:如何下载linux系统 编辑:程序博客网 时间:2024/05/18 06:19
文章转载自:http://blog.csdn.net/buptgshengod
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中写则不需要管权限,他的权限比较高
阅读全文
0 0
- android程序执行adb shell命令
- 在android程序中执行adb shell命令
- Android Java代码执行adb Shell命令
- Android Java代码执行adb Shell命令
- android apk 怎么执行adb shell命令
- Android Java代码执行adb Shell命令
- android ADB shell 命令启动 android程序
- 【android-tips】android程序执行adb shell命令(实例源码)
- C#执行adb shell命令
- Android adb shell 命令
- Android adb shell 命令
- Android adb shell 命令
- Android adb shell 命令
- Android adb shell 命令
- android adb shell命令
- android-adb shell命令
- android adb shell 命令
- Android adb shell 命令
- 习题5;5.1
- 简单的一个利用MVP做的登录
- HTML元素
- MySQL利用命令和PHP脚本创建删除一个数据库
- 机器学习实战_09_树回归_源代码错误修正
- android程序执行adb shell命令
- hashmap数据结构 数组+链表
- 是的,该对自己狠点了
- ES6系列之---数组新增的内置函数
- Android 控制线程的开始关闭
- 工作问题(SQL)
- 常用开发资源整理(持续更新)
- mysql安装在centos7报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
- (二)数组、指针、函数