Thursday, October 7, 2010

[Android Snippet] How to retrieve running process

Minimum API Level : 3

Key Class : ActivityManager , ActivityManager.RunningAppProcessInfo

Here is my Android code snippet showing how to retrieve information about application processes that are running on the device



ActivityManager manager = (ActivityManager)
getSystemService(Activity.ACTIVITY_SERVICE);
List list = manager.getRunningAppProcesses();
Log.v(TAG, "Got "+list.size()+" processes");

for(int i=0; i<list.size(); i++){
Log.v(TAG, "PID: "+list.get(i).pid+", Name: "+list.get(i).processName);
}

No comments:

Post a Comment