# PictureInPictureParamsCompat

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

*** ** * ** ***


```
public final class PictureInPictureParamsCompat
```

<br />

*** ** * ** ***

Helper class to access the framework `https://developer.android.com/reference/android/app/PictureInPictureParams.html`.

`https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat.Builder` is offered for a fluent API.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat.Builder` Builder class for `https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat`. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat#PictureInPictureParamsCompat(kotlin.Boolean,android.util.Rational,kotlin.collections.List,android.graphics.Rect,kotlin.Boolean,android.app.RemoteAction,android.util.Rational,kotlin.CharSequence,kotlin.CharSequence)( boolean isEnabled, https://developer.android.com/reference/android/util/Rational.html aspectRatio, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/RemoteAction.html> actions, https://developer.android.com/reference/android/graphics/Rect.html sourceRectHint, boolean isSeamlessResizeEnabled, https://developer.android.com/reference/android/app/RemoteAction.html closeAction, https://developer.android.com/reference/android/util/Rational.html expandedAspectRatio, https://developer.android.com/reference/java/lang/CharSequence.html title, https://developer.android.com/reference/java/lang/CharSequence.html subTitle )` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/RemoteAction.html>` | `https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat#getActions()()` Sets the user actions. |
| `final https://developer.android.com/reference/android/util/Rational.html` | `https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat#getAspectRatio()()` Sets the aspect ratio. |
| `final https://developer.android.com/reference/android/app/RemoteAction.html` | `https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat#getCloseAction()()` Sets a close action that should be invoked before the default close PiP action. |
| `final https://developer.android.com/reference/android/util/Rational.html` | `https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat#getExpandedAspectRatio()()` Sets the aspect ratio for the expanded picture-in-picture mode. |
| `final https://developer.android.com/reference/android/graphics/Rect.html` | `https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat#getSourceRectHint()()` Sets the window-coordinate bounds of an activity transitioning to picture-in-picture. |
| `final https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat#getSubTitle()()` Sets a subtitle for the picture-in-picture window, which may be displayed by the system to give the user more detailed information about what this PIP is displaying. |
| `final https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat#getTitle()()` Sets a title for the picture-in-picture window, which may be displayed by the system to give the user information about what this PIP is generally being used for. |
| `final boolean` | `https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat#isEnabled()()` This field indicates the PiP-able state of the application, and it will be translated to `https://developer.android.com/reference/android/app/PictureInPictureParams.html#isAutoEnterEnabled()` on API 31+. |
| `final boolean` | `https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat#isSeamlessResizeEnabled()()` Sets whether the system can seamlessly resize the window while the activity is in picture-in-picture mode. |

## Public constructors

### PictureInPictureParamsCompat

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

```
public PictureInPictureParamsCompat(
    boolean isEnabled,
    Rational aspectRatio,
    @NonNull List<@NonNull RemoteAction> actions,
    Rect sourceRectHint,
    boolean isSeamlessResizeEnabled,
    RemoteAction closeAction,
    Rational expandedAspectRatio,
    CharSequence title,
    CharSequence subTitle
)
```

## Public methods

### getActions

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

```
public final @NonNull List<@NonNull RemoteAction> getActions()
```

Sets the user actions. If there are more than `https://developer.android.com/reference/android/app/Activity.html#getMaxNumPictureInPictureActions()` actions, then the input list will be truncated to that number.

Compatibility notes: this field is used on API 26+

### getAspectRatio

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

```
public final Rational getAspectRatio()
```

Sets the aspect ratio. This aspect ratio is defined as the desired width / height, and does not change upon device rotation.

Compatibility notes: this field is used on API 26+

### getCloseAction

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

```
public final RemoteAction getCloseAction()
```

Sets a close action that should be invoked before the default close PiP action. The custom action must close the activity quickly using `https://developer.android.com/reference/android/app/Activity.html#finish()`. Otherwise, the system will forcibly close the PiP as if no custom close action was provided.

If the action matches one set via `https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat#(kotlin.Boolean,android.util.Rational,kotlin.collections.List,android.graphics.Rect,kotlin.Boolean,android.app.RemoteAction,android.util.Rational,kotlin.CharSequence,kotlin.CharSequence)` it may be shown in place of that custom action in the menu.

Compatibility notes: this field is used on API 33+

### getExpandedAspectRatio

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

```
public final Rational getExpandedAspectRatio()
```

Sets the aspect ratio for the expanded picture-in-picture mode. The aspect ratio is defined as the desired width / height. The aspect ratio cannot be changed from horizontal to vertical or vertical to horizontal while the PIP is shown. Any such changes will be ignored.

Setting the expanded ratio shows the activity's support for expanded mode.

Compatibility notes: this field is used on API 33+

### getSourceRectHint

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

```
public final Rect getSourceRectHint()
```

Sets the window-coordinate bounds of an activity transitioning to picture-in-picture. The bounds is the area of an activity that will be visible in the transition to picture-in-picture mode. For the best effect, these bounds should also match the aspect ratio in the arguments.

In Android 12+ these bounds are also reused to improve the exit transition from picture-in-picture mode. See the [Picture-in-Picture doc](https://developer.android.com/develop/ui/views/picture-in-picture#set-sourcerecthint) for more details.

Compatibility notes: this field is used on API 26+

### getSubTitle

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

```
public final CharSequence getSubTitle()
```

Sets a subtitle for the picture-in-picture window, which may be displayed by the system to give the user more detailed information about what this PIP is displaying.

Compatibility notes: this field is used on API 33+

### getTitle

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

```
public final CharSequence getTitle()
```

Sets a title for the picture-in-picture window, which may be displayed by the system to give the user information about what this PIP is generally being used for.

Compatibility notes: this field is used on API 33+

### isEnabled

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

```
public final boolean isEnabled()
```

This field indicates the PiP-able state of the application, and it will be translated to `https://developer.android.com/reference/android/app/PictureInPictureParams.html#isAutoEnterEnabled()` on API 31+.

### isSeamlessResizeEnabled

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

```
public final boolean isSeamlessResizeEnabled()
```

Sets whether the system can seamlessly resize the window while the activity is in picture-in-picture mode. This should normally be the case for video content and when it's set to `false`, system will perform transitions to overcome the artifacts due to resize.

Compatibility notes: this field is used on API 31+