I want to kill all running applications in android .so for this task , i implemented following code. But it is not working .App still remains in running.
Act
You have another possibility if the device is rooted (has superuser rights).
You can invoke an external process that would use the su rights. But note that it's probably a bad design as Android OS should be the only one to kill processes.
try {
Process rootProcess = Runtime.getRuntime().exec(new String[] { "su" });
String command = "kill - 9 ";
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(rootProcess.getOutputStream()), 2048);
try {
bw.write(command);
bw.newLine();
bw.flush();
} catch (IOException e) {
// Handle error
}
} catch (Exception e) {
e.printStackTrace();
// Device not rooted!
}