im trying to find the method behind having superuser access on android devices. basically i want my app to be able to remove system files, and so asking the user if its ok after the app is launched like most other apps, and then what code exactly am i looking to use to perform these sorts of actions? cant find much on google
thanks in advance!
SuperSU controls which other apps on your phone get root permissions. Whenever an app wants to request root permissions, it has to ask your SuperSU app, which will show a request prompt.
These “dangerous” permissions include access to your calling history, private messages, location, camera, microphone, and more. These permissions are not inherently dangerous, but have the potential for misuse. That's why Android gives you the opportunity to accept or refuse them.
If the device is rooted, you can use the following code to gain access to a root shell:
try
{
Process process = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(process.getOutputStream());
DataInputStream inputStream = new DataInputStream(process.getInputStream());
outputStream.writeBytes(command + "\n");
outputStream.flush();
outputStream.writeBytes("exit\n");
outputStream.flush();
process.waitFor();
}
catch (IOException e)
{
throw new Exception(e);
}
catch (InterruptedException e)
{
throw new Exception(e);
}
Where "command" is the command that you want to execute.
If I'm getting it right you want to grant your application root privileges. This is not possible with the standard Android image which is installed on the devices. The su command does not support changing to root.
You can however load a customized rooted ROM on your device other than that I'm afraid there is no solution.
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