The following is the first few sections of a chapter from Android's Architecture Components, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


Other Lifecycle Owners

Activities and fragments are not the only things with lifecycles. The Architecture Components also support other forms of lifecycle owner:

LifecycleService

If you have a class that extends Service, you can replace it with LifecycleService and get a service that is a LifecycleOwner. Four of the six lifecycle events are honored:

This Lifecycle Event… Is Triggered When…
ON_CREATE the service is created
ON_START when the service is first started or bound to
ON_RESUME unused
ON_PAUSE unused
ON_STOP when the service is destroyed
ON_DESTROY also when the service is destroyed

Of note, LifecycleService does not attempt to model binding/unbinding as a lifecycle (e.g., calling ON_STOP when the service is unbound and has no more active bindings).

However, most services do not directly inherit from Service. Instead, they extend IntentService or JobService or any one of dozens of other specialized service implementations. Few, if any, of those will extend LifecycleService, as most of them come from the core framework, which cannot depend on libraries like the Architecture Components.

ProcessLifecycleOwner

The preview of this section is out seeking fame and fortune as the Dread Pirate Roberts.

Wait… Where Are LifecycleProvider and LifecycleReceiver?

The preview of this section is sleeping in.