# PictureInPictureProvider

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

*** ** * ** ***

<br />

```
interface PictureInPictureProvider : OnPictureInPictureModeChangedProvider, OnPictureInPictureUiStateChangedProvider, OnUserLeaveHintProvider
```

<br />

Known direct subclasses [ComponentActivity](https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity` | Base class for activities that enables composition of higher level components. |

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

|---|---|
| `https://developer.android.com/reference/kotlin/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/kotlin/androidx/car/app/activity/BaseCarAppActivity` | Core logic for CarAppLibrary Activity interaction with a host. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/activity/CarAppActivity` | The class representing a car app activity in the main display. |
| `https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentActivity` | Base class for activities that want to use the support-based `https://developer.android.com/reference/kotlin/androidx/fragment/app/Fragment`. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/activity/LauncherActivity` | This class handles providing the right launcher activity when running native applications and Car App Library applications. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/PreviewActivity` | Activity used to run `@Composable` previews from Android Studio. |

*** ** * ** ***

Provider interface to support PiP (Picture-in-Picture) functionalities.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureProvider#enterPictureInPictureMode(androidx.core.app.PictureInPictureParamsCompat)(params: https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureParamsCompat)` Available since API 24 in the framework Activity class, puts the activity in picture-in-picture mode if possible in the current system state. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureProvider#setPictureInPictureParams(androidx.core.app.PictureInPictureParamsCompat)(params: https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureParamsCompat)` Available since API 26 in the framework Activity class, updates the properties of the picture-in-picture activity, or sets it to be used later when `https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureProvider#enterPictureInPictureMode(androidx.core.app.PictureInPictureParamsCompat)` is called |

### Inherited functions

From [androidx.core.app.OnPictureInPictureModeChangedProvider](https://developer.android.com/reference/kotlin/androidx/core/app/OnPictureInPictureModeChangedProvider) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/core/app/OnPictureInPictureModeChangedProvider#addOnPictureInPictureModeChangedListener(androidx.core.util.Consumer)(

listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureModeChangedInfo>

)`

Add a new listener that will get a callback associated with `https://developer.android.com/reference/android/app/Activity.html#onPictureInPictureModeChanged(boolean)` with the new `https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureModeChangedInfo`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/core/app/OnPictureInPictureModeChangedProvider#removeOnPictureInPictureModeChangedListener(androidx.core.util.Consumer)(

listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureModeChangedInfo>

)`

Remove a previously added listener.
From [androidx.core.app.OnPictureInPictureUiStateChangedProvider](https://developer.android.com/reference/kotlin/androidx/core/app/OnPictureInPictureUiStateChangedProvider) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/core/app/OnPictureInPictureUiStateChangedProvider#addOnPictureInPictureUiStateChangedListener(androidx.core.util.Consumer)(

listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureUiStateCompat>

)`

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/kotlin/androidx/core/app/PictureInPictureUiStateCompat`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/core/app/OnPictureInPictureUiStateChangedProvider#removeOnPictureInPictureUiStateChangedListener(androidx.core.util.Consumer)(

listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureUiStateCompat>

)`

Remove a previously added listener.
From [androidx.core.app.OnUserLeaveHintProvider](https://developer.android.com/reference/kotlin/androidx/core/app/OnUserLeaveHintProvider) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/core/app/OnUserLeaveHintProvider#addOnUserLeaveHintListener(java.lang.Runnable)(listener: https://developer.android.com/reference/java/lang/Runnable.html)`

Add a new listener that will get a callback associated with `https://developer.android.com/reference/android/app/Activity.html#onUserLeaveHint()`
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/core/app/OnUserLeaveHintProvider#removeOnUserLeaveHintListener(java.lang.Runnable)(listener: https://developer.android.com/reference/java/lang/Runnable.html)`

Remove a previously added listener.

## Public functions

### enterPictureInPictureMode

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

```
fun enterPictureInPictureMode(params: PictureInPictureParamsCompat): Unit
```

Available since API 24 in the framework Activity class, puts the activity in picture-in-picture mode if possible in the current system state. Any prior calls to `https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureProvider#setPictureInPictureParams(androidx.core.app.PictureInPictureParamsCompat)` will still apply when entering picture-in-picture through this call.

### setPictureInPictureParams

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

```
fun setPictureInPictureParams(params: PictureInPictureParamsCompat): Unit
```

Available since API 26 in the framework Activity class, updates the properties of the picture-in-picture activity, or sets it to be used later when `https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureProvider#enterPictureInPictureMode(androidx.core.app.PictureInPictureParamsCompat)` is called

| Parameters |
|---|---|
| `params: https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureParamsCompat` | `https://developer.android.com/reference/android/app/PictureInPictureParams.html` to use for picture-in-picture mode. |