public static boolean checkForRunningService ( Context ctx , String serviceClassName ) { ActivityManager manager = ( ActivityManager ) ctx . getSystemService ( Context . ACTIVITY_SERVICE ) ; for ( ActivityManager . RunningServiceInfo service : manager . getRunningServices ( Integer . MAX_VALUE ) ) { if ( serviceClassName . equals ( service . service . getClassName ( ) ) ) { return true ; } } return false ; }
Check for a running service