如何获取Android应用程序的根访问? [英] How to get Root Access for android app?

查看:223
本文介绍了如何获取Android应用程序的根访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个Android应用程序,我希望用户能够访问的数据目录。我知道你能做,调用Runtime.getRuntime()EXEC(苏); ,但我想,它打开了,如果你想获得,询问屏幕许可,但它并没有让我的话后,检索目录。这里是code:

  {尝试
                调用Runtime.getRuntime()EXEC(苏);
                最终文件数据文件= Environment.getDataDirectory();
                FileAdapter适配器=新FileAdapter(getActivity());
                adapter.setFiles(dataFile.listFiles());
                setListAdapter(适配器);
                setListShown(真);
            }赶上(IOException异常五){
                Toast.makeText(getActivity(),对不起,根访问被拒绝,Toast.LENGTH_LONG).show();
            }


解决方案

的Runtime.exec()单证说执行在一个单独的原生程序指定的程序。这意味着,它的新过程获取root权限。我认为你必须使用EXEC()是由返回过程对象,然后打开输出流并执行剩余的完成您的作业命令。您可以参考根工具源$ C ​​$ C更多信息如何做到这一点。

I am working on an android app, and I want the user to be able to access the data directory. I know you can do, Runtime.getRuntime().exec("su");, but I tried that and it opens up the screen that asks if you want to get permission, but it does not allow me to retrieve the directory after words. Here is the code:

try {
                Runtime.getRuntime().exec("su");
                final File dataFile = Environment.getDataDirectory();
                FileAdapter adapter = new FileAdapter(getActivity());
                adapter.setFiles(dataFile.listFiles());
                setListAdapter(adapter);
                setListShown(true);
            } catch (IOException e) {
                Toast.makeText(getActivity(),"Sorry, Root access was denied",Toast.LENGTH_LONG).show();
            }

解决方案

The Runtime.exec() documentations says Executes the specified program in a separate native process. Which means that, its the new process that gets the root access. I think you have to use the Process object that is returned by the exec() and open output stream and execute the remaining commands that accomplishes your job. You can refer to Root Tools source code for more info on how to do that.

这篇关于如何获取Android应用程序的根访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆