I,
Private boolean isMyServiceRunning (){
ActivityManager manager = (ActivityManager) getSystemService (Context. ACTIVITY_SERVICE );
For (RunningServiceInfo service: manager. getRunningServices (Integer. MAX_VALUE ))
{
If (MyService. class. getName (). equals (service. service. getClassName ()))
{
Returntrue;
}
}
Returnfalse;
}
2. startserver () must be used to start the service ()
Intent bindIntent = new Intent (this, ServiceTask. class );
StartService (bindIntent );
BindService (bindIntent, mConnection, 0 );
Public class servicerels {
Private static String LOG_TAG = servicerels. class. getName ();
Public static boolean isServiceRunning (String serviceClassName)
{
Final ActivityManager activityManager = (ActivityManager) Application. getContext (). getSystemService (Context. ACTIVITY_SERVICE );
Final List <RunningServiceInfo> services = activityManager. getRunningServices (Integer. MAX_VALUE );
For (RunningServiceInfo runningServiceInfo: services)
{
If (runningServiceInfo. service. getClassName (). equals (serviceClassName ))
{
Return true;
}
}
Return false;
}
}