Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.List;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;

import android.content.Context;

public class Main {

    public static boolean isStart(Context context) {
        ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List<RunningTaskInfo> tasks = am.getRunningTasks(100);
        if (tasks == null || tasks.size() == 0)
            return false;
        String name = "com.mid.market.service.MarketService";
        for (RunningTaskInfo task : tasks) {
            if (task.baseActivity.getClassName().equals(name)) {
                return true;
            }
        }
        return false;
    }
}