I want to stop or close apps which are running in background in android. Is it possible? If so how to achieve this. Refer any links will be appreciated.
Thanks in advance..
I want to stop or close apps which are running in background in android. Is it possible? If so how to achieve this. Refer any links will be appreciated.
Thanks in advance..
You can use
Process.killProcess(int pid)
to kill processes that have the same UID with your App. You can useActivityManager.killBackgroundProcesses(String packageName),with KILL_BACKGROUND_PROCESSES
permission in your manifest(for API >= 8) orActivityManager.restartPackage (String packageName)
(for API < 8) to kill specified process,except of forground process.So if you would to kill all other processes when your program is foreground process,you would to use
ActivityManager.killBackgroundProcesses
orActivityManager.restartPackage
:In above snippet code,each process will be killed unless it be process of your App or system process.