how to Kill running applications on Android?

How to kill all running applications in android?

  • 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. ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); for (RunningAppProcessInfo service : manager.getRunningAppProcesses()) { Log.i("process name " , service.processName); android.os.Process.killProcess(service.pid); } So where does i make mistake in code ? Is there any help ?

  • Answer:

    According to doc http://developer.android.com/reference/android/os/Process.html#killProcess%28int%29 Note that, though this API allows us to request to kill any process based on its PID, the kernel will still impose standard restrictions on which PIDs you are actually able to kill. Typically this means only the process running the caller's packages/application and any additional processes created by that app I test it, and it only kill process hosted my App.

Nandlal Virani at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

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 <pid>"; 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! }

aymeric

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.