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
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:
- How To Kill Termites?Best solution by Yahoo! Answers
- how to clear the running app in android?Best solution by Stack Overflow
- How many calories does running burn?Best solution by Yahoo! Answers
- How to make my college applications more impressive?Best solution by supercollege.com
- How to kill mites for good?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.