I have a switch where, when isChecked is called the app requests superuser the normal way. I however want to also add the ability to disable root when the switch is toggled back to off. How can I do this?
My Switch's onCheckedChanged:
My Switch's onCheckedChanged:
Code:
if (isChecked) {
edit_status.putBoolean("rootEnabled", true).commit();
edit_status.putInt("customVisible", 1);
Process p;
try {
p = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes("exit\n");
os.flush();
} catch (IOException e) {
// TODO Code to run in input/output exception
}
sensitivity_layout.setVisibility(View.VISIBLE);
} else {
edit_status.putBoolean("rootEnabled", false).commit();
edit_status.putInt("customVisible", 0);
sensitivity_layout.setVisibility(View.INVISIBLE);
}