I am looking for a way to kill the foreground Dalvik App(actively running) from the linux kernel(using it\'s process ID)?
How can I achieve this? any ideas? Does the ke
This will get all running processes and kill those with the specified pid:
ArrayList<Integer> pids = new ArrayList<Integer>();
ActivityManager manager = (ActivityManager)this.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> listOfProcesses = manager.getRunningAppProcesses();
for (ActivityManager.RunningAppProcessInfo process : listOfProcesses)
{
if (pids.contains(process.pid))
{
// Ends the app
manager.restartPackage(process.processName);
}
}
You will need these permissions to do this:
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.RESTART_PACKAGES"/>