Android examples for android.app:ActivityManager
is Service Running
import android.app.ActivityManager; import android.app.ActivityManager.RunningServiceInfo; import android.content.Context; public class Main { 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; }/*from ww w. ja va2 s . co m*/ } return false; } }