How to force stop launched process even running on front?
I am writing a task manager service and need to force close any running process, lets say browser, I tried using killBackgroundProcesses,restartPackage,killProcess but none of these force closes process ( e.g browser ) when process is on front else they are working.
I want to force stop the process even when process is running on front. What should I开发者_Go百科 do now ??
Solved, here is the code:
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
Appmgr.killBackgroundProcesses(RunningP.processName);
I had this problem like you.I used a method in the service that killed the background process.So whenever i need to kill process that is running in the foreground i just brought my Activity in the foreground.So the process want to kill automatically goes background and can be killed with killBackgroundProcess.
But surely this is not really a good practice
精彩评论