Class ApiService.Listener (2.4.0)

public abstract static class ApiService.Listener

A listener for the various state changes that a ApiService goes through in its lifecycle.

All methods are no-ops by default, implementors should override the ones they care about.

Inheritance

java.lang.Object > ApiService.Listener

Constructors

Listener()

public Listener()

Methods

failed(ApiService.State from, Throwable failure)

public void failed(ApiService.State from, Throwable failure)

Called when the service transitions to the FAILED state. The FAILED state is a terminal state in the transition diagram. Therefore, if this method is called, no other methods will be called on the Listener.

Parameters
NameDescription
fromApiService.State

The previous state that is being transitioned from. Failure can occur in any state with the exception of NEW or TERMINATED.

failureThrowable

The exception that caused the failure.

running()

public void running()

Called when the service transitions from STARTING to RUNNING. This occurs when a service has successfully started.

starting()

public void starting()

Called when the service transitions from NEW to STARTING. This occurs when ApiService#startAsync is called the first time.

stopping(ApiService.State from)

public void stopping(ApiService.State from)

Called when the service transitions to the STOPPING state. The only valid values for from are STARTING or RUNNING. This occurs when ApiService#stopAsync is called.

Parameter
NameDescription
fromApiService.State

The previous state that is being transitioned from.

terminated(ApiService.State from)

public void terminated(ApiService.State from)

Called when the service transitions to the TERMINATED state. The TERMINATED state is a terminal state in the transition diagram. Therefore, if this method is called, no other methods will be called on the Listener.

Parameter
NameDescription
fromApiService.State

The previous state that is being transitioned from. The only valid values for this are NEW, RUNNING or STOPPING.