Check if service is running on Android?
l want to check if a service is running l wrote this code public class startServiceOrNo { public static void startServiceIfItsNotRuning(Class<?> class1, Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (class1.getName().equals(service.service.getClassName())) { Lg.d("servisstart SERVICE ALREADY START" + class1.getName()); return; } } Lg.d("servisstart SSERVICE NEW SERVIS " + class1.getName()); context.startService(new Intent(context, class1));