runtime = Runtime.getruntime ();
The effect of this sentence in Java is to obtain a computer terminal, for example, under Window is a DOS window, such as: Runtime.exec ("Color 2D") and directly under DOS directly input color 2D effect.
In wirelessly equivalent to get to the Linux terminal.
To get root access for Android apps, the Android device must have root access first.
How the app gets root permissions: Let the app's code execute the directory to get the highest permissions. chmod 777 [Code Execution directory] in Linux
/**
* Application Run command to get root permission, the device must be cracked (root access)
*
* @return App Yes/no get root permissions
*/
public static Boolean upgraderootpermission (String pkgcodepath) {
Process process = NULL;
DataOutputStream OS = null;
try {
String cmd= "chmod 777" + Pkgcodepath;
Process = Runtime.getruntime (). EXEC ("su"); Switch to root account
OS = new DataOutputStream (Process.getoutputstream ());
Os. WriteChars (cmd+ "\ n");
Os. WriteChars ("exit\n");
Os.flush ();
Process.waitfor ();
} catch (Exception e) {
return false;
} finally {
try {
if (OS! = null) {
Os.close ();
}
Process.destroy ();
} catch (Exception e) {
}
}
return true;
}
Where pkgcodepath can be obtained by Getpackagecodepath ()
No root privileges required, only declaration: <uses-permission android:name= "Android.permission.READ_LOGS"/>
Can get the phone all the log information, that is, in the development of logcat inside the content displayed, this part of the content by WindowManager maintenance.
1. You can see what apps the user installed.
2. You can see your own application errors, convenient post-software maintenance log crawl.
Android App request root permission