# OnPictureInPictureUiStateChangedProvider

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/app/OnPictureInPictureUiStateChangedProvider.kt+class:androidx.core.app.OnPictureInPictureUiStateChangedProvider) Added in [1.18.0](https://developer.android.com/jetpack/androidx/releases/core#1.18.0)

*** ** * ** ***


```
public interface OnPictureInPictureUiStateChangedProvider
```

<br />

Known direct subclasses [PictureInPictureProvider](https://developer.android.com/reference/androidx/core/app/PictureInPictureProvider)

|---|---|
| `https://developer.android.com/reference/androidx/core/app/PictureInPictureProvider` | Provider interface to support PiP (Picture-in-Picture) functionalities. |

Known indirect subclasses [AppCompatActivity](https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity), [BaseCarAppActivity](https://developer.android.com/reference/androidx/car/app/activity/BaseCarAppActivity), [CarAppActivity](https://developer.android.com/reference/androidx/car/app/activity/CarAppActivity), [ComponentActivity](https://developer.android.com/reference/androidx/activity/ComponentActivity), [FragmentActivity](https://developer.android.com/reference/androidx/fragment/app/FragmentActivity), [LauncherActivity](https://developer.android.com/reference/androidx/car/app/activity/LauncherActivity)

|---|---|
| `https://developer.android.com/reference/androidx/appcompat/app/AppCompatActivity` | Base class for activities that wish to use some of the newer platform features on older Android devices. |
| `https://developer.android.com/reference/androidx/car/app/activity/BaseCarAppActivity` | Core logic for CarAppLibrary Activity interaction with a host. |
| `https://developer.android.com/reference/androidx/car/app/activity/CarAppActivity` | The class representing a car app activity in the main display. |
| `https://developer.android.com/reference/androidx/activity/ComponentActivity` | Base class for activities that enables composition of higher level components. |
| `https://developer.android.com/reference/androidx/fragment/app/FragmentActivity` | Base class for activities that want to use the support-based `https://developer.android.com/reference/androidx/fragment/app/Fragment`. |
| `https://developer.android.com/reference/androidx/car/app/activity/LauncherActivity` | This class handles providing the right launcher activity when running native applications and Car App Library applications. |

*** ** * ** ***

Interface for components that can dispatch calls from `https://developer.android.com/reference/android/app/Activity.html#onPictureInPictureUiStateChanged(android.app.PictureInPictureUiState)`.

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/core/app/OnPictureInPictureUiStateChangedProvider#addOnPictureInPictureUiStateChangedListener(androidx.core.util.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/app/PictureInPictureUiStateCompat> listener )` Add a new listener that will get a callback associated with `https://developer.android.com/reference/android/app/Activity.html#onPictureInPictureUiStateChanged(android.app.PictureInPictureUiState)` with the new `https://developer.android.com/reference/androidx/core/app/PictureInPictureUiStateCompat`. |
| `abstract void` | `https://developer.android.com/reference/androidx/core/app/OnPictureInPictureUiStateChangedProvider#removeOnPictureInPictureUiStateChangedListener(androidx.core.util.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/app/PictureInPictureUiStateCompat> listener )` Remove a previously added listener. |

## Public methods

### addOnPictureInPictureUiStateChangedListener

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

```
abstract void addOnPictureInPictureUiStateChangedListener(
    @NonNull Consumer<@NonNull PictureInPictureUiStateCompat> listener
)
```

Add a new listener that will get a callback associated with `https://developer.android.com/reference/android/app/Activity.html#onPictureInPictureUiStateChanged(android.app.PictureInPictureUiState)` with the new `https://developer.android.com/reference/androidx/core/app/PictureInPictureUiStateCompat`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/app/PictureInPictureUiStateCompat> listener` | The listener that should be called whenever `https://developer.android.com/reference/android/app/Activity.html#onPictureInPictureUiStateChanged(android.app.PictureInPictureUiState)` was called. |

### removeOnPictureInPictureUiStateChangedListener

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

```
abstract void removeOnPictureInPictureUiStateChangedListener(
    @NonNull Consumer<@NonNull PictureInPictureUiStateCompat> listener
)
```

Remove a previously added listener. It will not receive any future callbacks.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/app/PictureInPictureUiStateCompat> listener` | The listener previously added with `https://developer.android.com/reference/androidx/core/app/OnPictureInPictureUiStateChangedProvider#addOnPictureInPictureUiStateChangedListener(androidx.core.util.Consumer)` that should be removed. |