Code example for Context

Methods: getPackageNamegetSystemService

     * @param context 
     * @return true if another application is above this one. 
    public static boolean isApplicationBroughtToBackground(final Context context) {
        ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List<RunningTaskInfo> tasks = am.getRunningTasks(1);
        if (!tasks.isEmpty()) {
            ComponentName topActivity = tasks.get(0).topActivity;
            if (!topActivity.getPackageName().equals(context.getPackageName())) {
                return true; 
        return false; 
     * Determines whether an application is about to close, in which case it will invoke the 
     * {@link DroidFuApplication#onClose()} life-cycle handler. Application close is being defined 
Stop searching for code, let great code find you!  Add Codota to your java IDE