List of usage examples for android.app ActivityManager getRunningServices
@Deprecated public List<RunningServiceInfo> getRunningServices(int maxNum) throws SecurityException
From source file:Main.java
public static boolean isServiceRunning(Context context, Class<?> serviceClass) { final ActivityManager activityManager = (ActivityManager) context .getSystemService(Context.ACTIVITY_SERVICE); final List<ActivityManager.RunningServiceInfo> services = activityManager .getRunningServices(Integer.MAX_VALUE); for (ActivityManager.RunningServiceInfo runningServiceInfo : services) { if (runningServiceInfo.service.getClassName().equals(serviceClass.getName())) { return true; }//from w ww .j a v a2s .c o m } return false; }
From source file:Main.java
public static boolean isServiceRunning(Context context, String service) { ActivityManager actManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ArrayList<ActivityManager.RunningServiceInfo> serviceList = (ArrayList<ActivityManager.RunningServiceInfo>) actManager .getRunningServices(50);//from www. ja v a2 s . com for (int n = 0; n < serviceList.size(); n++) { if (serviceList.get(n).service.getClassName().toString().equals(service)) { return true; } } return false; }
From source file:id.zelory.tanipedia.util.Utils.java
public static boolean isMyServiceRunning(Class<?> serviceClass, Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClass.getName().equals(service.service.getClassName())) { return true; }/*w w w .ja va 2 s.co m*/ } return false; }
From source file:Main.java
public static boolean isServiceRunning(Context mContext, String className) { boolean isRunning = false; android.app.ActivityManager activityManager = (android.app.ActivityManager) mContext .getSystemService(Context.ACTIVITY_SERVICE); List<android.app.ActivityManager.RunningServiceInfo> serviceList = activityManager .getRunningServices(Integer.MAX_VALUE); if (serviceList.size() == 0) { return false; }/*www . j av a 2s . co m*/ for (int i = 0; i < serviceList.size(); i++) { if (serviceList.get(i).service.getClassName().equals(className) == true) { isRunning = true; break; } } return isRunning; }
From source file:org.anoopam.main.anoopamaudio.UtilFunctions.java
/** * Check if service is running or not//from ww w. j ava 2 s. c om * @param serviceName * @param context * @return */ public static boolean isServiceRunning(String serviceName, Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceName.equals(service.service.getClassName())) { return true; } } return false; }
From source file:Main.java
public static final boolean checkServiceRunning(Context c, Class<? extends Service> cls) { ComponentName service = new ComponentName(c, cls); ActivityManager am = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE); if (am == null) throw new RuntimeException("Cannot check running services: ActivityManager is not available"); for (ActivityManager.RunningServiceInfo runningService : am.getRunningServices(Integer.MAX_VALUE)) { if (runningService.service.equals(service)) return true; }/*from w w w. j av a2 s .co m*/ return false; }
From source file:com.bukanir.android.utils.Utils.java
public static boolean isServiceRunning(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (Torrent2HttpService.class.getName().equals(service.service.getClassName())) { return true; }//w ww .j av a 2 s . c om } return false; }
From source file:com.bukanir.android.utils.Utils.java
public static boolean isHttpServiceRunning(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (BukanirHttpService.class.getName().equals(service.service.getClassName())) { return true; }/*from w w w . j a v a2s . c om*/ } return false; }
From source file:com.weihuoya.bboo._G.java
public static boolean isServiceRunning(String className) { if (mRunningServices == null) { ActivityManager manager = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE); mRunningServices = manager.getRunningServices(Integer.MAX_VALUE); }//from www . jav a 2 s . c o m for (ActivityManager.RunningServiceInfo info : mRunningServices) { if (info.service.getClassName().equals(className)) { return true; } } return false; }
From source file:org.restcomm.app.utillib.Utils.Global.java
public static boolean isMainServiceRunning(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ("com.cortxt.app.corelib.MainService".equals(service.service.getClassName())) { return true; }/* w ww.j a v a2s. co m*/ } return false; }