Android examples for App:App Running
is App Running
//package com.java2s; 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; }/*from w ww . j av a 2 s . c om*/ String packageName = context.getPackageName(); for (RunningTaskInfo info : list) { if (info.topActivity.getPackageName().equals(packageName)) { isRunning = true; break; } } return isRunning; } }