# DefaultLifecycleObserver

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

*** ** * ** ***


```
public interface DefaultLifecycleObserver extends LifecycleObserver
```

<br />

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

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

*** ** * ** ***

Callback interface for listening to `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner` state changes.

If a class implements both this interface and `https://developer.android.com/reference/androidx/lifecycle/LifecycleEventObserver`, the methods of `https://developer.android.com/reference/androidx/lifecycle/DefaultLifecycleObserver` are called first, followed by `https://developer.android.com/reference/androidx/lifecycle/LifecycleEventObserver#onStateChanged(androidx.lifecycle.LifecycleOwner,androidx.lifecycle.Lifecycle.Event)`.

Note: If a class implements this interface and also uses the deprecated `androidx.lifecycle.OnLifecycleEvent` annotations, those annotations are ignored.

## Summary

| ### Public methods |
|---|---|
| `default void` | `https://developer.android.com/reference/androidx/lifecycle/DefaultLifecycleObserver#onCreate(androidx.lifecycle.LifecycleOwner)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner)` Notifies that `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_CREATE` event occurred. |
| `default void` | `https://developer.android.com/reference/androidx/lifecycle/DefaultLifecycleObserver#onDestroy(androidx.lifecycle.LifecycleOwner)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner)` Notifies that `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_DESTROY` event occurred. |
| `default void` | `https://developer.android.com/reference/androidx/lifecycle/DefaultLifecycleObserver#onPause(androidx.lifecycle.LifecycleOwner)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner)` Notifies that `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_PAUSE` event occurred. |
| `default void` | `https://developer.android.com/reference/androidx/lifecycle/DefaultLifecycleObserver#onResume(androidx.lifecycle.LifecycleOwner)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner)` Notifies that `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_RESUME` event occurred. |
| `default void` | `https://developer.android.com/reference/androidx/lifecycle/DefaultLifecycleObserver#onStart(androidx.lifecycle.LifecycleOwner)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner)` Notifies that `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_START` event occurred. |
| `default void` | `https://developer.android.com/reference/androidx/lifecycle/DefaultLifecycleObserver#onStop(androidx.lifecycle.LifecycleOwner)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner)` Notifies that `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_STOP` event occurred. |

## Public methods

### onCreate

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.4.0)

```
default void onCreate(@NonNull LifecycleOwner owner)
```

Notifies that `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_CREATE` event occurred.

Called after the `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`'s `onCreate` method returns.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner` | The component whose state changed. |

### onDestroy

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.4.0)

```
default void onDestroy(@NonNull LifecycleOwner owner)
```

Notifies that `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_DESTROY` event occurred.

Called before the `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`'s `onDestroy` method is called.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner` | The component whose state changed. |

### onPause

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.4.0)

```
default void onPause(@NonNull LifecycleOwner owner)
```

Notifies that `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_PAUSE` event occurred.

Called before the `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`'s `onPause` method is called.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner` | The component whose state changed. |

### onResume

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.4.0)

```
default void onResume(@NonNull LifecycleOwner owner)
```

Notifies that `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_RESUME` event occurred.

Called after the `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`'s `onResume` method returns.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner` | The component whose state changed. |

### onStart

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.4.0)

```
default void onStart(@NonNull LifecycleOwner owner)
```

Notifies that `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_START` event occurred.

Called after the `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`'s `onStart` method returns.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner` | The component whose state changed. |

### onStop

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.4.0)

```
default void onStop(@NonNull LifecycleOwner owner)
```

Notifies that `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_STOP` event occurred.

Called before the `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner`'s `onStop` method is called.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner owner` | The component whose state changed. |