Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

```
class Builder
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.app.PictureInPictureParams.Builder](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#) |

Builder class for `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams` objects.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#Builder()()` Default constructor |
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#Builder(android.app.PictureInPictureParams)(original: https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams)` Copy constructor |

| Public methods ||
|---|---|
| open [PictureInPictureParams](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams)! | `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#build()()` <br /> |
| open [PictureInPictureParams.Builder](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#setActions(kotlin.collections.MutableList)(actions: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://developer.android.com/reference/kotlin/android/app/RemoteAction!>!)` Sets the user actions. |
| open [PictureInPictureParams.Builder](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#) | `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#setActions(kotlin.collections.MutableList,%20android.app.RemoteAction)(actions: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://developer.android.com/reference/kotlin/android/app/RemoteAction!>?, primaryAction: https://developer.android.com/reference/kotlin/android/app/RemoteAction?)` Sets the user actions and a primary action. |
| open [PictureInPictureParams.Builder](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#setAspectRatio(android.util.Rational)(aspectRatio: https://developer.android.com/reference/kotlin/android/util/Rational.html#!)` Sets the aspect ratio. |
| open [PictureInPictureParams.Builder](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#) | `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#setAutoEnterEnabled(kotlin.Boolean)(autoEnterEnabled: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets whether the system will automatically put the activity in picture-in-picture mode without needing/waiting for the activity to call `https://developer.android.com/reference/kotlin/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)`. |
| open [PictureInPictureParams.Builder](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#) | `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#setCloseAction(android.app.RemoteAction)(action: https://developer.android.com/reference/kotlin/android/app/RemoteAction?)` Sets a close action that should be invoked before the default close PiP action. |
| open [PictureInPictureParams.Builder](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#) | `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#setExpandedAspectRatio(android.util.Rational)(expandedAspectRatio: https://developer.android.com/reference/kotlin/android/util/Rational.html#?)` Sets the aspect ratio for the expanded picture-in-picture mode. |
| open [PictureInPictureParams.Builder](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#) | `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#setOverlayActions(kotlin.collections.MutableList,%20android.app.RemoteAction)(overlayActions: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://developer.android.com/reference/kotlin/android/app/RemoteAction!>?, primaryOverlayAction: https://developer.android.com/reference/kotlin/android/app/RemoteAction?)` Sets the overlay actions and a primary overlay action. |
| open [PictureInPictureParams.Builder](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#) | `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#setSeamlessResizeEnabled(kotlin.Boolean)(seamlessResizeEnabled: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets whether the system can seamlessly resize the window while the activity is in picture-in-picture mode. |
| open [PictureInPictureParams.Builder](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#)! | `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#setSourceRectHint(android.graphics.Rect)(launchBounds: https://developer.android.com/reference/kotlin/android/graphics/Rect.html#!)` Sets the window-coordinate bounds of an activity transitioning to picture-in-picture. |
| open [PictureInPictureParams.Builder](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#) | `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#setSubtitle(kotlin.CharSequence)(subtitle: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html?)` 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. |
| open [PictureInPictureParams.Builder](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#) | `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#setTitle(kotlin.CharSequence)(title: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html?)` 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. |

## Public constructors

### Builder

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
Builder()
```

Default constructor

### Builder

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
Builder(original: PictureInPictureParams)
```

Copy constructor

| Parameters ||
|---|---|
| `original` | [PictureInPictureParams](https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams): `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams` instance this builder is built upon. This value cannot be `null`. |

## Public methods

### build

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun build(): PictureInPictureParams!
```

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams!` | an immutable `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams` to be used when entering or updating the activity in picture-in-picture. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)`
- `https://developer.android.com/reference/kotlin/android/app/Activity#setPictureInPictureParams(android.app.PictureInPictureParams)`

### setActions

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun setActions(actions: MutableList<RemoteAction!>!): PictureInPictureParams.Builder!
```

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

| Parameters ||
|---|---|
| `actions` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[RemoteAction](https://developer.android.com/reference/kotlin/android/app/RemoteAction)!\>!: the new actions to show in the picture-in-picture menu. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#!` | this builder instance. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/RemoteAction`

### setActions

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun setActions(
    actions: MutableList<RemoteAction!>?, 
    primaryAction: RemoteAction?
): PictureInPictureParams.Builder
```

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

If the primary action is valid, the system would use a modern UI for the PiP menu.

| Parameters ||
|---|---|
| `actions` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[RemoteAction](https://developer.android.com/reference/kotlin/android/app/RemoteAction)!\>?: the new actions to show in the picture-in-picture menu. This value may be `null`. |
| `primaryAction` | [RemoteAction](https://developer.android.com/reference/kotlin/android/app/RemoteAction)?: to be used as the primary action in the PiP menu. This action MUST be one of the actions set via `actions`. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#` | this builder instance. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/RemoteAction`

### setAspectRatio

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun setAspectRatio(aspectRatio: Rational!): PictureInPictureParams.Builder!
```

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

| Parameters ||
|---|---|
| `aspectRatio` | [Rational](https://developer.android.com/reference/kotlin/android/util/Rational.html#)!: the new aspect ratio for the activity in picture-in-picture, must be between 2.39:1 and 1:2.39 (inclusive). |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#!` | this builder instance. |

### setAutoEnterEnabled

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun setAutoEnterEnabled(autoEnterEnabled: Boolean): PictureInPictureParams.Builder
```

Sets whether the system will automatically put the activity in picture-in-picture mode without needing/waiting for the activity to call `https://developer.android.com/reference/kotlin/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)`. If true, `https://developer.android.com/reference/kotlin/android/app/Activity#onPictureInPictureRequested()` will never be called. This property is `false` by default.

| Parameters ||
|---|---|
| `autoEnterEnabled` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` if the system will automatically put the activity in picture-in-picture mode. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#` | this builder instance. This value cannot be `null`. |

### setCloseAction

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun setCloseAction(action: RemoteAction?): PictureInPictureParams.Builder
```

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/kotlin/android/app/Activity#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/kotlin/android/app/PictureInPictureParams.Builder#setActions(kotlin.collections.MutableList)` it may be shown in place of that custom action in the menu.

| Parameters ||
|---|---|
| `action` | [RemoteAction](https://developer.android.com/reference/kotlin/android/app/RemoteAction)?: to replace the system close action. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#` | this builder instance. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/RemoteAction`

### setExpandedAspectRatio

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun setExpandedAspectRatio(expandedAspectRatio: Rational?): PictureInPictureParams.Builder
```

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.   
Requires the `https://developer.android.com/reference/kotlin/android/content/pm/PackageManager.html#FEATURE_EXPANDED_PICTURE_IN_PICTURE:kotlin.String` feature which can be detected using `https://developer.android.com/reference/kotlin/android/content/pm/PackageManager.html#hasSystemFeature(kotlin.String)`.

| Parameters ||
|---|---|
| `expandedAspectRatio` | [Rational](https://developer.android.com/reference/kotlin/android/util/Rational.html#)?: must not be between 2.39:1 and 1:2.39 (inclusive). If `null`, expanded picture-in-picture mode is not supported. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#` | this builder instance. This value cannot be `null`. |

### setOverlayActions

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun setOverlayActions(
    overlayActions: MutableList<RemoteAction!>?, 
    primaryOverlayAction: RemoteAction?
): PictureInPictureParams.Builder
```

Sets the overlay actions and a primary overlay action. If there are more than `https://developer.android.com/reference/kotlin/android/app/Activity#getMaxNumPictureInPictureOverlayActions()` actions, then the input list will be truncated to that number.

Unlike the standard actions set via `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#setActions(kotlin.collections.MutableList)`, these actions are rendered prominently as an overlay and are visible without requiring the user to tap on the window to reveal the menu.

| Parameters ||
|---|---|
| `overlayActions` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[RemoteAction](https://developer.android.com/reference/kotlin/android/app/RemoteAction)!\>?: The actions to show in the picture-in-picture window overlay. Typically, for a media app, this action list can contain a Call-To-Action (CTA) and Skip action. This value may be `null`. |
| `primaryOverlayAction` | [RemoteAction](https://developer.android.com/reference/kotlin/android/app/RemoteAction)?: The action to be used as the primary action in the picture-in-picture window overlay. This action MUST be one of the actions set via `overlayActions`. For instance, a media app can use this to highlight a Call-to-Action (CTA) button while an ad is playing. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#` | this builder instance. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/RemoteAction`

### setSeamlessResizeEnabled

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun setSeamlessResizeEnabled(seamlessResizeEnabled: Boolean): PictureInPictureParams.Builder
```

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. This property is `true` by default for backwards compatibility.

| Parameters ||
|---|---|
| `seamlessResizeEnabled` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` if the system can seamlessly resize the window while activity is in picture-in-picture mode. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#` | this builder instance. This value cannot be `null`. |

### setSourceRectHint

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun setSourceRectHint(launchBounds: Rect!): PictureInPictureParams.Builder!
```

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 [Support smoother animations when exiting out of PiP mode](https://developer.android.com/develop/ui/views/picture-in-picture#smoother-exit) for more details.

| Parameters ||
|---|---|
| `launchBounds` | [Rect](https://developer.android.com/reference/kotlin/android/graphics/Rect.html#)!: window-coordinate bounds indicating the area of the activity that will still be visible following the transition into picture-in-picture (e.g. the video view bounds in a video player) |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#!` | this builder instance. |

### setSubtitle

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun setSubtitle(subtitle: CharSequence?): PictureInPictureParams.Builder
```

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.  
Setting a title via `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#setTitle(kotlin.CharSequence)` should be prioritized. Subtitles longer than 1024 characters (default) are automatically truncated.

| Parameters ||
|---|---|
| `subtitle` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?: Details about the PIP content. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#` | this builder instance. This value cannot be `null`. |

### setTitle

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun setTitle(title: CharSequence?): PictureInPictureParams.Builder
```

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. Titles longer than 1024 characters (default) are automatically truncated.

| Parameters ||
|---|---|
| `title` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?: General information about the PIP content. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/PictureInPictureParams.Builder#` | this builder instance. This value cannot be `null`. |