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.
I saw this link in the documentation, and especially noted the FACTORY_TEST
permission:
public static final String FACTORY_TEST
Since: API Level 1
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"
Is that the best way?
If it's not possible using the SDK, how can I make a "root" application work?
In most versions of Android, that goes like this: Head to Settings, tap Security, scroll down to Unknown Sources and toggle the switch to the on position. Now you can install KingoRoot. Then run the app, tap One Click Root, and cross your fingers. If all goes well, your device should be rooted within about 60 seconds.
user-permission-sdk-23 specifies that the app that wants a particular permission is running on SDK version 23 or higher. It is used when you update your app to run SDK 23 elements and the users running a lower API which does not support the new elements. Android manifest - user permissions.
Please note that android emulators already are "rooted". You do not need to do anything to get a root adb shell, as it already runs as root by default.
What you need to do is something like:
Process root = Runtime.getRuntime().exec("su");
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With