get running processes - Android Android OS

Android examples for Android OS:Process

Description

get running processes

Demo Code


//package com.java2s;
import java.util.List;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;

public class Main {
    private static ActivityManager am = null;

    /**/*from  ww w. j  a v  a2 s . c om*/
     * get running processes
     * @return list of running process
     */
    public static List<RunningAppProcessInfo> getRunningProcesses(
            Context context) {
        if (am == null) {
            am = (ActivityManager) context
                    .getSystemService(Context.ACTIVITY_SERVICE);
        }
        return am.getRunningAppProcesses();
    }
}

Related Tutorials