Android APK Information Get isApplicationBroughtToBackground(Context context)

Here you can find the source of isApplicationBroughtToBackground(Context context)

Description

is Application Brought To Background

Declaration

public static boolean isApplicationBroughtToBackground(Context context) 

Method Source Code

//package com.java2s;

import java.util.List;

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

public class Main {
    public static boolean isApplicationBroughtToBackground(Context context) {
        ActivityManager am = (ActivityManager) context
                .getSystemService(Context.ACTIVITY_SERVICE);
        List<RunningTaskInfo> tasks = am.getRunningTasks(1);
        if (tasks != null && !tasks.isEmpty()) {
            ComponentName topActivity = tasks.get(0).topActivity;
            if (!topActivity.getPackageName().equals(
                    context.getPackageName())) {
                return true;
            }//w ww .jav a  2s. com
        }
        return false;
    }
}

Related

  1. getAppLabel(Context c, int uid)
  2. getAppPkg(Context c, int uid)
  3. getAppPkg(Context c, int uid)
  4. getNameApkInstalledFile(String packageName, int type)
  5. isAppPlatformSignature(Context ctx)
  6. isApplicationSentToBackground( final Context context)
  7. restoreToUserApp(Context context)
  8. getApplicationName(Context context)
  9. getAppName(Context context)