# androidx.core.pip.contentpip

*** ** * ** ***

## Interfaces

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/ContentPipCallback` | A callback interface for managing the handoff of a content between the main activity and the Content PiP. |

## Classes

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/ContentPipToken` | Token holding the registered callbacks and observers used to manage Picture-in-Picture (PiP) for content inside a `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity`. |

## Extension functions summary

|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/package-summary#(androidx.activity.ComponentActivity).disablePipOnAppSwitch(androidx.core.pip.contentpip.ContentPipToken)( contentPipToken: https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/ContentPipToken )` Disables entering PiP on app switch for this Activity with Content PiP. |
| `https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/ContentPipToken` | `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/package-summary#(androidx.activity.ComponentActivity).enablePipOnAppSwitch(androidx.core.pip.contentpip.ContentPipCallback)(callback: https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/ContentPipCallback)` Enables entering PiP on app switch for this Activity with Content PiP. |

## Extension functions

### ComponentActivity.disablePipOnAppSwitch

Artifact: [androidx.core:core-pip](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/pip/contentpip/ContentPipExt.kt+function:disablePipOnAppSwitch) Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/core#1.0.0-alpha04)

```
fun ComponentActivity.disablePipOnAppSwitch(
    contentPipToken: ContentPipToken
): Unit
```

Disables entering PiP on app switch for this Activity with Content PiP.

This method unregisters the listeners and observers that were added by `https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/package-summary#(androidx.activity.ComponentActivity).enablePipOnAppSwitch(androidx.core.pip.contentpip.ContentPipCallback)`. It restores the original window callback and stops monitoring lifecycle and exit hints.

**Threading:** This method must be called on the main thread of your application.

| Parameters |
|---|---|
| `contentPipToken: https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/ContentPipToken` | The token returned by `https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/package-summary#(androidx.activity.ComponentActivity).enablePipOnAppSwitch(androidx.core.pip.contentpip.ContentPipCallback)`. |

### ComponentActivity.enablePipOnAppSwitch

Artifact: [androidx.core:core-pip](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/pip/contentpip/ContentPipExt.kt+function:enablePipOnAppSwitch) Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/core#1.0.0-alpha04)

```
fun ComponentActivity.enablePipOnAppSwitch(callback: ContentPipCallback): ContentPipToken
```

Enables entering PiP on app switch for this Activity with Content PiP.

This API hooks into standard Activity exit hints to trigger a fallback PiP pipeline when native [Auto-Enter](https://developer.android.com/reference/android/app/PictureInPictureParams#isAutoEnterEnabled()) is suppressed by the OS (e.g. on Quick Switch).

It also automatically monitors the Activity lifecycle and user interactions to "pull back" the player and terminate the fallback task when the user returns to the app.

It is recommended to call this method from `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity#onCreate(android.os.Bundle)`, if it is called multiple times, only the last `https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/ContentPipCallback` is effective.

**Threading:** This callback is strictly tied to the UI toolkit and will **always** be executed synchronously on the main thread of your application.

| Parameters |
|---|---|
| `callback: https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/ContentPipCallback` | The callback to manage handoff between tasks. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/ContentPipToken` | `https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/ContentPipToken` that caller can pass to `https://developer.android.com/reference/kotlin/androidx/core/pip/contentpip/package-summary#(androidx.activity.ComponentActivity).disablePipOnAppSwitch(androidx.core.pip.contentpip.ContentPipToken)`. |