Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.app.ActivityManager;
import android.content.Context;

import java.util.List;

public class Main {
    public static boolean isAppRunningForeground(Context context) {
        ActivityManager var1 = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List list = var1.getRunningTasks(1);
        return context.getPackageName()
                .equalsIgnoreCase(((ActivityManager.RunningTaskInfo) list.get(0)).baseActivity.getPackageName());
    }
}