I need to find solution, for killing all foreign applications, except a list of allowed applications (this is task for our corporate managers with Android tablets).
Now, I killing foreign applications in this way (code works by timer in service, each 2 sec):
if (killThisProcess) {
Log.i("Process to KILL: ", appProcess.processName);
// kill app
activityManager.killBackgroundProcesses(appProcess.processName);
}
This code works, but only when application in background. User can launch application, do something, and only after application will be in background, it will be killed.
How can I kill process, when it in foreground mode, just after launching?
Thanks.