is Running Process by Package - Android Android OS

Android examples for Android OS:Process

Description

is Running Process by Package

Demo Code


//package com.java2s;
import android.app.ActivityManager;

import java.util.List;

public class Main {
    public static boolean isRunningProcess(ActivityManager activityManager,
            String packageName) {
        boolean isRunning = false;
        List<ActivityManager.RunningAppProcessInfo> processInfos = activityManager
                .getRunningAppProcesses();
        for (ActivityManager.RunningAppProcessInfo processInfo : processInfos) {
            if (processInfo.processName.equals(packageName)) {
                isRunning = true;/*from   ww  w.  jav  a 2s . co m*/
                break;
            }
        }
        return isRunning;
    }
}

Related Tutorials