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) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo serviceInfo : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClass.getName().equals(serviceInfo.service.getClassName())) { return true; }//from www. ja v a 2 s . com } return false; }
From source file:Main.java
public static boolean isServiceRunning(Context ctx, String className) { boolean isRunning = false; ActivityManager activityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> servicesList = activityManager.getRunningServices(Integer.MAX_VALUE); Iterator<RunningServiceInfo> l = servicesList.iterator(); while (l.hasNext()) { RunningServiceInfo si = (RunningServiceInfo) l.next(); if (className.equals(si.service.getClassName())) { isRunning = true;// w w w . ja v a2s. c o m } } return isRunning; }
From source file:Main.java
/** * Check if service is running or not//from w w w. j a v a2 s . c o m * * @param serviceName * @param context * @return */ public static boolean isServiceRunning(String serviceName, Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceName.equals(service.service.getClassName())) { return true; } } return false; }
From source file:Main.java
public static boolean isServiceRunning(Context context, String className) { boolean isRunning = false; ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> servicesList = activityManager.getRunningServices(Integer.MAX_VALUE); for (RunningServiceInfo si : servicesList) { if (className.equals(si.service.getClassName())) { isRunning = true;/*from ww w . ja v a2 s . c om*/ } } return isRunning; }
From source file:Main.java
/** * To check if the specified service is running. * This util needs `android.permission.GET_TASKS` permission. * * @param context the context//from w w w . ja v a 2 s . com * @param className class name of service * @return true if the service is running */ public static boolean isServiceRunning(Context context, String className) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo info : manager.getRunningServices(Integer.MAX_VALUE)) { if (info.service.getClassName().equals(className)) { return true; } } return false; }
From source file:Main.java
/** * Check if a service is running/*from www.ja v a 2 s . co m*/ * @param context * @param serviceClassName - complete name of service * @return */ public static boolean isServiceRunning(Context context, String serviceClassName) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClassName.equals(service.service.getClassName())) { return true; } } return false; }
From source file:Main.java
public static boolean isRunningServer(String className, Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> runningServices = activityManager.getRunningServices(1000); for (RunningServiceInfo runningServiceInfo : runningServices) { ComponentName service = runningServiceInfo.service; String className2 = service.getClassName(); if (className2.equals(className)) { return true; }//from ww 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; }/*w ww. j a va2s . c o m*/ } return false; }
From source file:Main.java
public static boolean isServiceRunning(Class<? extends Service> service, Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo runningServiceInfo : manager .getRunningServices(Integer.MAX_VALUE)) { if (service.getName().equals(runningServiceInfo.service.getClassName())) { return true; }/* ww w . java 2 s .c o m*/ } return false; }
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. java 2s .co m } return false; }