I have a service A that needs to be notified about another service B. I bind service B to service A by calling following method that should not start the service , as stated in this question.
serviceA.bindService(new Intent(serviceA, ServiceB.class), conn, 0);
However when I want to check if service is running following method return true even if service is just bound.
public static boolean isServiceRunning(Context context) {
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (ServiceB.class.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
Why does isServiceRunning
return true for service that is just bound and not running (I checked that service is not running by looking into running apps in settings) ?