Java tutorial
//package com.java2s; //License from project: Apache License import java.util.List; import android.app.ActivityManager; import android.app.ActivityManager.RunningTaskInfo; import android.content.Context; public class Main { public static boolean isServiceRunning(Context context, String className) { boolean isServiceFound = false; try { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningTaskInfo> services = activityManager.getRunningTasks(Integer.MAX_VALUE); for (int i = 0; i < services.size(); i++) { if (services.get(i).topActivity.getClassName().equalsIgnoreCase(className)) { isServiceFound = true; } } } catch (Exception ex) { } return isServiceFound; } }