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, String serviceName) { ActivityManager manger = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> rs = manger.getRunningServices(50); for (RunningServiceInfo rsi : rs) { String className = rsi.service.getClassName(); if (className.equals(serviceName)) { return true; }//from w ww . java2 s .c om } return false; }
From source file:Main.java
public static boolean isMyServiceRunning(Context c, String name) { ActivityManager manager = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (name.equals(service.service.getClassName())) { return true; }/*from w w w .j a v a2 s . co m*/ } return false; }
From source file:Main.java
public static final boolean checkServiceRunning(final Context context, final String serviceName) { final ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (final RunningServiceInfo info : manager.getRunningServices(Integer.MAX_VALUE)) { if (info.service.getClassName().equals(serviceName) && info.pid > 0) { return true; }/* w w w .jav a 2 s.c o m*/ } return false; }
From source file:Main.java
public static boolean isMyServiceRunning(Context context, Class<?> serviceClass) { 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; }/*from w w w.j a v a2 s . co m*/ return false; }
From source file:Main.java
public static boolean isServiceRunning(Context context, String serviceName) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { //Log.d(LOG_TAG,"Service: " + service.service.getClassName() + "; " + service.pid + "; " + service.clientCount + "; " + service.foreground + "; " + service.process); if (serviceName.equals(service.service.getClassName())) { return true; }//from w ww .j a v a2s . c o m } return false; }
From source file:Main.java
public static boolean isServiceRunning(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; }//from w w w . j ava 2s. c o m } return false; }
From source file:Main.java
public static ActivityManager.RunningServiceInfo getServiceInfo(Context context, Class<? extends Service> cls) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo info : manager.getRunningServices(Integer.MAX_VALUE)) { if (cls.getName().equals(info.service.getClassName())) { return info; }/*from ww w.ja v a2s . c o m*/ } return null; }
From source file:Main.java
public static boolean isServiceRunning(Context context, Class<?> serviceClass) { 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.j a va 2 s . co m*/ } return false; }
From source file:Main.java
public static Set getAllRunningService(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> infos = activityManager.getRunningServices(0x7FFFFFFF); Set<String> names = new HashSet<>(); if (infos == null || infos.size() == 0) return null; for (RunningServiceInfo info : infos) { names.add(info.service.getClassName()); }/*from w w w .j a v a 2 s. c o m*/ return names; }
From source file:Main.java
/** * Check whether my service is running.//ww w . j a va 2s .c o m * @param context application's context * @param serviceClass class of the service to look for * @return true if the service is running, false otherwise */ public static boolean isMyServiceRunning(Context context, Class<?> serviceClass) { 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; return false; }