[英]How can I give root permission to my Android app?
I'm trying to use linux command in my app. 我正在尝试在我的应用程序中使用linux命令。 But I failed to get root permission.
但是我没有获得root许可。 Could you please let me know how to get root permission?
您能否让我知道如何获得root权限?
String[] cmd = {"su"};
String result_process2 = runProcess2(cmd);
public String runProcess2(String[] cmd) {
try {
Process process = Runtime.getRuntime().exec(cmd);
It looks like doesn't work. 看来不起作用。 One thing weird is I found su in /system/xbin, but when I check this directory through ls in app, su file didn't exist there.
奇怪的是我在/ system / xbin中找到了su,但是当我在应用程序中通过ls检查此目录时,那里没有su文件。
Command is 命令是
String ls = "ls -al /system/xbin/";
String resultls = runProcess((String)ls);
public String runProcess(String arg) {
try {
Process process = Runtime.getRuntime().exec(arg);
Do you know why I couldn't see su file in /system/xbin/ even though it can be found through adb shell in my laptop? 您知道为什么即使可以通过笔记本电脑的adb shell找到su文件,在/ system / xbin /中也看不到su文件吗?
A standard Android device does not have access to root privileges. 标准Android设备无法访问root特权。 In order to attain this you will have to root the device.
为了达到这个目的,您将必须根设备。 See this link for more information.
有关更多信息,请参见此链接。
As for why you can find the file through the ADB shell and not from within the app is probably that you don't have read access for the file outside the ADB shell. 至于为什么可以通过ADB Shell而不是从应用程序内部找到文件的原因,可能是您对ADB Shell之外的文件没有读取权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.