Android examples for android.app:ActivityManager
Check if service is running or not
import android.app.ActivityManager; import android.content.Context; public class Main { /**/* w w w. java 2 s . co m*/ * Check if service is running or not * * @param serviceName * @param context * @return */ public static boolean isServiceRunning(String serviceName, Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (serviceName.equals(service.service.getClassName())) { return true; } } return false; } }