is Process Running - Android Android OS

Android examples for Android OS:Process

Description

is Process Running

Demo Code


//package com.java2s;

import android.app.ActivityManager;

import android.content.Context;

import java.util.List;

public class Main {

    public static boolean isProessRunning(Context context, String proessName) {
        boolean isRunning = false;
        ActivityManager am = (ActivityManager) context
                .getSystemService(Context.ACTIVITY_SERVICE);

        List<ActivityManager.RunningAppProcessInfo> lists = am
                .getRunningAppProcesses();
        for (ActivityManager.RunningAppProcessInfo info : lists) {
            if (info.processName.equals(proessName)) {
                isRunning = true;/*from  www .  j  a  va 2  s . c  o  m*/
                return isRunning;
            }
        }

        return isRunning;
    }
}

Related Tutorials