Java tutorial
//package com.java2s; import android.app.*; import android.content.*; import java.util.List; public class Main { public static boolean isApplicationBroughtToBackground(Context context) { List list = ((ActivityManager) context.getSystemService("activity")).getRunningTasks(1); boolean flag; if (!list.isEmpty() && !((android.app.ActivityManager.RunningTaskInfo) list.get(0)).topActivity .getPackageName().equals(context.getPackageName())) flag = true; else flag = false; return flag; } }