I am writing an app that intercepts the launching of apps, killing them, then restarting them if certain permissions are met. I've managed to figure out the first part(launching of apps) by having a service that monitors the system log. I'm now working on killing the app that was just launched. I'm trying to use:
ActivityManager.killBackgroundProcesses(packageName);
but I'm not sure if this will kill the entire app, including all services/tasks that it starts. I've tried using killBackgroundProcesses() to indiscriminately kill all apps that are launching, but the app still seems to start.
I've also tried android.os.Process.killProcess(pid), passing the other app's pid, however the app still seems to start as well.