# ServiceLifecycleDispatcher

added in [version 1.1.0](https://developer.android.com/topic/libraries/support-library/revisions)   
belongs to Maven artifact android.arch.lifecycle:extensions:1.1.1  
Summary: [Ctors](https://developer.android.com/reference/android/arch/lifecycle/ServiceLifecycleDispatcher#pubctors) \| [Methods](https://developer.android.com/reference/android/arch/lifecycle/ServiceLifecycleDispatcher#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/arch/lifecycle/ServiceLifecycleDispatcher#inhmethods)  

# ServiceLifecycleDispatcher

| The `android.arch` Architecture Components packages are no longer maintained. They have been superseded by the corresponding [androidx.\*](https://developer.android.com/jetpack/androidx/migrate) packages. See [androidx.lifecycle.ServiceLifecycleDispatcher](https://developer.android.com/reference/androidx/lifecycle/ServiceLifecycleDispatcher) instead.


`
public


class
ServiceLifecycleDispatcher
`


`

extends Object


`

`


`

|---|---------------------------------------------------|
| java.lang.Object                                     ||
| ↳ | android.arch.lifecycle.ServiceLifecycleDispatcher |

<br />

*** ** * ** ***

Helper class to dispatch lifecycle events for a service. Use it only if it is impossible
to use [LifecycleService](https://developer.android.com/reference/android/arch/lifecycle/LifecycleService).

## Summary

|                                                                                                                                            ### Public constructors                                                                                                                                             ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[ServiceLifecycleDispatcher](https://developer.android.com/reference/android/arch/lifecycle/ServiceLifecycleDispatcher#ServiceLifecycleDispatcher(android.arch.lifecycle.LifecycleOwner))`(`[LifecycleOwner](https://developer.android.com/reference/android/arch/lifecycle/LifecycleOwner)` provider) ` |

|                                                                                                                                                                                                                                                                                                 ### Public methods                                                                                                                                                                                                                                                                                                 ||
|------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[Lifecycle](https://developer.android.com/reference/android/arch/lifecycle/Lifecycle) | ` `[getLifecycle](https://developer.android.com/reference/android/arch/lifecycle/ServiceLifecycleDispatcher#getLifecycle())`() `                                                                                                                                                                                                                                                                                                                                                                                         |
| ` void`                                                                                  | ` `[onServicePreSuperOnBind](https://developer.android.com/reference/android/arch/lifecycle/ServiceLifecycleDispatcher#onServicePreSuperOnBind())`() ` Must be a first call in [onBind(Intent)](https://developer.android.com/reference/android/app/Service.html#onBind(android.content.Intent)) method, even before super.onBind call.                                                                                                                                                                                  |
| ` void`                                                                                  | ` `[onServicePreSuperOnCreate](https://developer.android.com/reference/android/arch/lifecycle/ServiceLifecycleDispatcher#onServicePreSuperOnCreate())`() ` Must be a first call in [onCreate()](https://developer.android.com/reference/android/app/Service.html#onCreate()) method, even before super.onCreate call.                                                                                                                                                                                                    |
| ` void`                                                                                  | ` `[onServicePreSuperOnDestroy](https://developer.android.com/reference/android/arch/lifecycle/ServiceLifecycleDispatcher#onServicePreSuperOnDestroy())`() ` Must be a first call in [onDestroy()](https://developer.android.com/reference/android/app/Service.html#onDestroy()) method, even before super.OnDestroy call.                                                                                                                                                                                               |
| ` void`                                                                                  | ` `[onServicePreSuperOnStart](https://developer.android.com/reference/android/arch/lifecycle/ServiceLifecycleDispatcher#onServicePreSuperOnStart())`() ` Must be a first call in [onStart(Intent, int)](https://developer.android.com/reference/android/app/Service.html#onStart(android.content.Intent, int)) or [onStartCommand(Intent, int, int)](https://developer.android.com/reference/android/app/Service.html#onStartCommand(android.content.Intent, int, int)) methods, even before a corresponding super call. |

| ### Inherited methods |
|-----------------------|---|
| From class ` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public constructors

### ServiceLifecycleDispatcher

added in [version 1.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ServiceLifecycleDispatcher (LifecycleOwner provider)
```

<br />

<br />

|                                                                                     Parameters                                                                                     ||
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `provider` | `LifecycleOwner`: [LifecycleOwner](https://developer.android.com/reference/android/arch/lifecycle/LifecycleOwner) for a service, usually it is a service itself <br /> |

## Public methods

### getLifecycle

added in [version 1.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Lifecycle getLifecycle ()
```

<br />

<br />

|                                                                                                                                              Returns                                                                                                                                              ||
|---------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Lifecycle](https://developer.android.com/reference/android/arch/lifecycle/Lifecycle) | [Lifecycle](https://developer.android.com/reference/android/arch/lifecycle/Lifecycle) for the given [LifecycleOwner](https://developer.android.com/reference/android/arch/lifecycle/LifecycleOwner) <br /> |

### onServicePreSuperOnBind

added in [version 1.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onServicePreSuperOnBind ()
```

Must be a first call in [onBind(Intent)](https://developer.android.com/reference/android/app/Service.html#onBind(android.content.Intent)) method, even before super.onBind
call.

<br />

### onServicePreSuperOnCreate

added in [version 1.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onServicePreSuperOnCreate ()
```

Must be a first call in [onCreate()](https://developer.android.com/reference/android/app/Service.html#onCreate()) method, even before super.onCreate call.

<br />

### onServicePreSuperOnDestroy

added in [version 1.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onServicePreSuperOnDestroy ()
```

Must be a first call in [onDestroy()](https://developer.android.com/reference/android/app/Service.html#onDestroy()) method, even before super.OnDestroy
call.

<br />

### onServicePreSuperOnStart

added in [version 1.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onServicePreSuperOnStart ()
```

Must be a first call in [onStart(Intent, int)](https://developer.android.com/reference/android/app/Service.html#onStart(android.content.Intent, int)) or
[onStartCommand(Intent, int, int)](https://developer.android.com/reference/android/app/Service.html#onStartCommand(android.content.Intent, int, int)) methods, even before
a corresponding super call.

<br />

-

  ## Annotations

  - [OnLifecycleEvent](https://developer.android.com/reference/android/arch/lifecycle/OnLifecycleEvent)
-

  ## Interfaces

  - [DefaultLifecycleObserver](https://developer.android.com/reference/android/arch/lifecycle/DefaultLifecycleObserver)
  - [LifecycleObserver](https://developer.android.com/reference/android/arch/lifecycle/LifecycleObserver)
  - [LifecycleOwner](https://developer.android.com/reference/android/arch/lifecycle/LifecycleOwner)
  - [LifecycleRegistryOwner](https://developer.android.com/reference/android/arch/lifecycle/LifecycleRegistryOwner)
  - [Observer](https://developer.android.com/reference/android/arch/lifecycle/Observer)
  - [ViewModelProvider.Factory](https://developer.android.com/reference/android/arch/lifecycle/ViewModelProvider.Factory)
  - [ViewModelStoreOwner](https://developer.android.com/reference/android/arch/lifecycle/ViewModelStoreOwner)
-

  ## Classes

  - [AndroidViewModel](https://developer.android.com/reference/android/arch/lifecycle/AndroidViewModel)
  - [Lifecycle](https://developer.android.com/reference/android/arch/lifecycle/Lifecycle)
  - [LifecycleRegistry](https://developer.android.com/reference/android/arch/lifecycle/LifecycleRegistry)
  - [LifecycleService](https://developer.android.com/reference/android/arch/lifecycle/LifecycleService)
  - [LiveData](https://developer.android.com/reference/android/arch/lifecycle/LiveData)
  - [LiveDataReactiveStreams](https://developer.android.com/reference/android/arch/lifecycle/LiveDataReactiveStreams)
  - [MediatorLiveData](https://developer.android.com/reference/android/arch/lifecycle/MediatorLiveData)
  - [MutableLiveData](https://developer.android.com/reference/android/arch/lifecycle/MutableLiveData)
  - [ProcessLifecycleOwner](https://developer.android.com/reference/android/arch/lifecycle/ProcessLifecycleOwner)
  - [ServiceLifecycleDispatcher](https://developer.android.com/reference/android/arch/lifecycle/ServiceLifecycleDispatcher)
  - [Transformations](https://developer.android.com/reference/android/arch/lifecycle/Transformations)
  - [ViewModel](https://developer.android.com/reference/android/arch/lifecycle/ViewModel)
  - [ViewModelProvider](https://developer.android.com/reference/android/arch/lifecycle/ViewModelProvider)
  - [ViewModelProvider.AndroidViewModelFactory](https://developer.android.com/reference/android/arch/lifecycle/ViewModelProvider.AndroidViewModelFactory)
  - [ViewModelProvider.NewInstanceFactory](https://developer.android.com/reference/android/arch/lifecycle/ViewModelProvider.NewInstanceFactory)
  - [ViewModelProviders](https://developer.android.com/reference/android/arch/lifecycle/ViewModelProviders)
  - [ViewModelProviders.DefaultFactory](https://developer.android.com/reference/android/arch/lifecycle/ViewModelProviders.DefaultFactory)
  - [ViewModelStore](https://developer.android.com/reference/android/arch/lifecycle/ViewModelStore)
  - [ViewModelStores](https://developer.android.com/reference/android/arch/lifecycle/ViewModelStores)
-

  ## Enums

  - [Lifecycle.Event](https://developer.android.com/reference/android/arch/lifecycle/Lifecycle.Event)
  - [Lifecycle.State](https://developer.android.com/reference/android/arch/lifecycle/Lifecycle.State)