List of usage examples for android.app ActivityManager getRunningServices
@Deprecated public List<RunningServiceInfo> getRunningServices(int maxNum) throws SecurityException
From source file:Main.java
/** * @param ctx// w w w .ja v a 2 s .c o m * @param serviceClass * @return */ public static boolean isServiceRunning(Context ctx, Class<?> serviceClass) { ActivityManager manager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClass.getName().equals(service.service.getClassName())) { return true; } } return false; }
From source file:Main.java
public static boolean isServiceWork(Context mContext, String serviceName) { boolean isWork = false; ActivityManager myAM = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> myList = myAM.getRunningServices(140); if (myList.size() <= 0) { return false; }//from w w w . j a v a2 s . c o m for (int i = 0; i < myList.size(); i++) { String mName = myList.get(i).service.getClassName().toString(); if (mName.equals(serviceName)) { isWork = true; break; } } return isWork; }
From source file:Main.java
/** * Check for a running service/* w w w .ja v a2 s . c o m*/ * * @param ctx the application context * @param serviceClassName the service class name * @return true if service is running, false overwise */ public static boolean checkForRunningService(Context ctx, String serviceClassName) { ActivityManager manager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClassName.equals(service.service.getClassName())) { return true; } } return false; }
From source file:Main.java
/** * check whether specific service is running. * @param context// w w w .ja va2 s . com * @param serviceClassFullName the full class name of service * @return true if service is running */ public static boolean isServiceRunning(Context context, String serviceClassFullName) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> runningServices = manager.getRunningServices(1024); for (ActivityManager.RunningServiceInfo info : runningServices) { if (info.getClass().getName().equals(serviceClassFullName)) return true; } return false; }
From source file:Main.java
public static boolean isServiceRunning(Context context, String serviceName) { if (TextUtils.isEmpty(serviceName)) { return false; }//from w w w.j ava 2 s . c om ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> mServiceList = manager.getRunningServices(100); for (int i = 0; i < mServiceList.size(); i++) { String clasString = mServiceList.get(i).service.getClassName(); if (clasString.equals(serviceName)) { return true; } } 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 = l.next(); if (className.equals(si.service.getClassName())) { isRunning = true;/*from w w w.j a va2 s . c om*/ } } return isRunning; }
From source file:Main.java
/** * Check if the Jarvis services are running. * @param context - the context of the calling application. * @param serviceName - the name of the service. * @return <b>True</b> if the service is running,<br/><b>False</b> if the service is not running. * @author Vibhor/*www .j a va 2s. co m*/ */ public static boolean isIrisServiceRunning(Context context, String serviceName) { 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 isRun(Context context, Class<?> clazz) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> serviceList = activityManager .getRunningServices(Integer.MAX_VALUE); if (!(serviceList.size() > 0)) { return false; }/*from w w w . ja v a 2 s . c o m*/ for (int i = 0; i < serviceList.size(); i++) { if (serviceList.get(i).service.getClassName().equals(clazz.getName())) { return true; } } return false; }
From source file:Main.java
/** * Function to check if a Service is running. * * @param serviceClass The service's class. * @return true if running, else false./* w w w. j a va 2s . c o m*/ */ private static boolean serviceIsRunning(Class<?> serviceClass, Activity activity) { ActivityManager manager = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceClass.getName().equals(service.service.getClassName())) { return true; } } 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<ActivityManager.RunningServiceInfo> servicesList = activityManager .getRunningServices(Integer.MAX_VALUE); Iterator<ActivityManager.RunningServiceInfo> l = servicesList.iterator(); while (l.hasNext()) { ActivityManager.RunningServiceInfo si = (ActivityManager.RunningServiceInfo) l.next(); if (className.equals(si.service.getClassName())) { isRunning = true;//from w w w. j a va 2 s. c o m } } return isRunning; }