get Running Process Count - Android Android OS

Android examples for Android OS:Process

Description

get Running Process Count

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 {

    public static int getRunningPocessCount(Context context) {
        List<RunningAppProcessInfo> runningAppProcessInfos = getManager(
                context).getRunningAppProcesses();
        int count = runningAppProcessInfos.size();
        return count;
    }//from ww  w .ja  va2 s .  co  m

    public static ActivityManager getManager(Context context) {
        return (ActivityManager) context
                .getSystemService(Context.ACTIVITY_SERVICE);
    }
}

Related Tutorials