# LifecycleObserver

Artifact: [androidx.lifecycle:lifecycle-common](https://developer.android.com/jetpack/androidx/releases/lifecycle) [View Source](https://cs.android.com/search?q=file:androidx/lifecycle/LifecycleObserver.kt+class:androidx.lifecycle.LifecycleObserver) Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.0.0)

*** ** * ** ***

Common/AllAndroid/JVM
- Cmn

  ```
  interface LifecycleObserver
  ```
Known direct subclasses [DefaultLifecycleObserver](https://developer.android.com/reference/kotlin/androidx/lifecycle/DefaultLifecycleObserver), [LifecycleEventObserver](https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleEventObserver)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/DefaultLifecycleObserver` | Callback interface for listening to `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner` state changes. |
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleEventObserver` | Interface for receiving any `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.Event` state changes. |

Known indirect subclasses [AmbientLifecycleObserver](https://developer.android.com/reference/kotlin/androidx/wear/ambient/AmbientLifecycleObserver)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/wear/ambient/AmbientLifecycleObserver` | Interface for LifecycleObservers which are used to add ambient mode support to activities on Wearable devices. |

*** ** * ** ***

Marker interface that indicates a class is a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleObserver`.

This interface is the common type for all lifecycle observer implementations. It allows you to add any observer type to a `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle` using `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle#addObserver(androidx.lifecycle.LifecycleObserver)`.

**Deprecation Note** : Do not implement this interface directly. The `lifecycle-compiler` annotation processor and annotating methods with `@OnLifecycleEvent` are deprecated.

Implement one of the following interfaces instead:

- `https://developer.android.com/reference/kotlin/androidx/lifecycle/DefaultLifecycleObserver` (Recommended): Implement this interface to receive specific lifecycle callbacks (such as `onCreate`, `onStart`, and others) using overridden methods.

- `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleEventObserver`: Implement this interface if you need to handle all lifecycle event state transitions in a single `onStateChanged` callback.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle` | for details and usage patterns. |