Here you can find the source of isServiceRunning(Context ctx, Class> serviceClass)
static boolean isServiceRunning(Context ctx, Class<?> serviceClass)
//package com.java2s; //License from project: Open Source License import android.app.ActivityManager; import android.app.ActivityManager.RunningServiceInfo; import android.content.Context; public class Main { static boolean isServiceRunning(Context ctx, Class<?> serviceClass) { ActivityManager manager = (ActivityManager) ctx .getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager .getRunningServices(Integer.MAX_VALUE)) { if (serviceClass.getName().equals( service.service.getClassName())) { return true; }//from w w w .java2s . c o m } return false; } }