如何通过 Android SDK 获得 root 权限? [英] How can I get root permissions through the Android SDK?

查看:24
本文介绍了如何通过 Android SDK 获得 root 权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 Android 编程,我想制作一个必须以 root 身份运行的应用程序.合乎逻辑的做法是在 Android 清单中添加根权限.

I'm learning Android programming, and I want to make an application which has to run as root. The logical thing would be to add a root permission in the Android Manifest.

我在文档中看到了这个链接,特别指出FACTORY_TEST 权限:

I saw this link in the documentation, and especially noted the FACTORY_TEST permission:

public static final String FACTORY_TEST

自:API 级别 1

作为制造商测试运行应用程序,以 root 用户身份运行.仅当设备处于在制造商测试模式下运行.常数值:android.permission.FACTORY_TEST"

Run as a manufacturer test application, running as the root user. Only available when the device is running in manufacturer test mode. Constant Value: "android.permission.FACTORY_TEST"

这是最好的方法吗?

如果无法使用 SDK,我该如何使根"应用程序正常工作?

If it's not possible using the SDK, how can I make a "root" application work?

推荐答案

你需要做的是:

Process root = Runtime.getRuntime().exec("su");

这会导致 SuperUser 显示,这让您可以从 root 访问权限中允许或阻止它.如果用户没有 root,这种方法可能不起作用.这里是一种方法你可以测试一下.

That causes SuperUser to show, which lets you either Allow or Block it from root access. This approach might not work if the user is not rooted. Here is a way you can test it.

这篇关于如何通过 Android SDK 获得 root 权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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