Getting a list of running processes and killing a specific process

I am executing the following code snippet:

ActivityManager actvityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
List<RunningTaskInfo> procInfos = actvityManager.getRunningTasks(1000);

Then I kill one process that interests me with

actvityManager.killBackgroundProcesses(process.baseActivity.getPackageName());

where processis the entry from procInfos.

The problem is that if I run getRunningTasksit again , it will still show the process I'm (presumably) killed, and the task manager for Android listed this process before the call killBackgroundProcessesand removed it from the list after this call.

So, any ideas on how the task manager gets a list of running processes? And is it normal that I successfully killed a third-party process on an untouched device?

+5
source share
1 answer

"" , ; , - .

ActivityManager.getRunningTasks() , , , , .

+5

All Articles