简体   繁体   English

如何授予我的Android应用根权限?

[英]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.

相关问题 在尝试访问文件系统之前,如何确保我的Android 6 Cordova应用程序提示用户授予权限? - How can I ensure that my Android 6 Cordova app prompts the user to give permission before attempting to access the filesystem? 如何在Android上为Catlog授予root权限 - How to give root permission for Catlog on Android 如何为我的App android设置默认短信权限? - How can i set default SMS permission to my App android? 如何以root权限编译Android内核? - How can I compile an Android kernel with root permission? Android应用root权限? - Android app root permission? 如何为我的Android应用程序提供系统密码锁定模式? - How can I give System password locking pattern to my Android app? 如何赠送免费的付费Android应用副本? - How can I give away a free copy of my paid Android app? 如何为我的 android 应用程序获得可怕的 WRITE_SECURE_SETTINGS 权限? - How can I get the dreaded WRITE_SECURE_SETTINGS permission for my android app? 可以给一个它没有要求的 android 应用程序权限吗? - can one give an android app permission it didn't ask for? 一个应用程序可以将其权限授予 android 中的另一个应用程序吗? - Can an app give its permission to another application in android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM