Java tutorial
//package com.java2s; //License from project: Apache License import android.app.ActivityManager; import android.content.Context; import java.util.Iterator; import java.util.List; public class Main { 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; } } return isRunning; } }