Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

import java.util.List;

public class Main {

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

        List<android.app.ActivityManager.RunningAppProcessInfo> lists = am.getRunningAppProcesses();
        for (android.app.ActivityManager.RunningAppProcessInfo info : lists) {
            if (info.processName.equals(proessName)) {
                isRunning = true;
                return isRunning;
            }
        }

        return isRunning;
    }
}