We would like to know how to is App Running.
//from ww w . j a va 2 s .c o m import java.util.List; import android.app.ActivityManager; import android.app.ActivityManager.RunningTaskInfo; import android.content.Context; public class Main { public static boolean isAppRunning(Context context) { boolean isRunning = false; ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningTaskInfo> list = am.getRunningTasks(100); if (list.size() <= 0) { return false; } String packageName = context.getPackageName(); for (RunningTaskInfo info : list) { if (info.topActivity.getPackageName().equals(packageName)) { isRunning = true; break; } } return isRunning; } }