Android 获取系统权限的代码
16lz
2021-01-23
Android 获取系统权限的代码
public static boolean runRootCommand(String command) { Process process = null; DataOutputStream os = null; try { process = Runtime.getRuntime().exec("su"); os = new DataOutputStream(process.getOutputStream()); os.writeBytes(command+"\n"); os.writeBytes("exit\n"); os.flush(); process.waitFor(); } catch (Exception e) { Log.d("*** DEBUG ***", "Unexpected error - Here is what I know: "+e.getMessage()); return false; } finally { try { if (os != null) { os.close(); } process.destroy(); } catch (Exception e) { // nothing } } return true; }}
更多相关文章
- 编译代码报出Android library projects cannot be launched错误
- 解决Eclipse3.6中Android 代码自动补全卡死的问题
- (安卓权限)Android Permissions
- android 下测试网络的丢包率和延迟 的代码
- 《Android/OPhone 开发完全讲义》已出版,现提供源代码下载
- 如何关联androidSDK源代码
- Unity2019通过unity获取Android动态权限(不用在Android写插件)