Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#inhmethods)

# PictureInPictureParams.Builder

*** ** * ** ***


`
public
static


class
PictureInPictureParams.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.PictureInPictureParams.Builder |

<br />

*** ** * ** ***

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

## Summary

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

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/app/PictureInPictureParams` | ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#build()() ` |
| ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#setActions(java.util.List<android.app.RemoteAction>,%20android.app.RemoteAction)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/RemoteAction> actions, https://developer.android.com/reference/android/app/RemoteAction primaryAction) ` Sets the user actions and a primary action. |
| ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#setActions(java.util.List<android.app.RemoteAction>)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/RemoteAction> actions) ` Sets the user actions. |
| ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#setAspectRatio(android.util.Rational)(https://developer.android.com/reference/android/util/Rational aspectRatio) ` Sets the aspect ratio. |
| ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#setAutoEnterEnabled(boolean)(boolean autoEnterEnabled) ` 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/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)`. |
| ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#setCloseAction(android.app.RemoteAction)(https://developer.android.com/reference/android/app/RemoteAction action) ` Sets a close action that should be invoked before the default close PiP action. |
| ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#setExpandedAspectRatio(android.util.Rational)(https://developer.android.com/reference/android/util/Rational expandedAspectRatio) ` Sets the aspect ratio for the expanded picture-in-picture mode. |
| ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#setOverlayActions(java.util.List<android.app.RemoteAction>,%20android.app.RemoteAction)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/RemoteAction> overlayActions, https://developer.android.com/reference/android/app/RemoteAction primaryOverlayAction) ` Sets the overlay actions and a primary overlay action. |
| ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#setSeamlessResizeEnabled(boolean)(boolean seamlessResizeEnabled) ` Sets whether the system can seamlessly resize the window while the activity is in picture-in-picture mode. |
| ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#setSourceRectHint(android.graphics.Rect)(https://developer.android.com/reference/android/graphics/Rect launchBounds) ` Sets the window-coordinate bounds of an activity transitioning to picture-in-picture. |
| ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#setSubtitle(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence subtitle) ` 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. |
| ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | ` https://developer.android.com/reference/android/app/PictureInPictureParams.Builder#setTitle(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence title) ` 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. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


## Public constructors

### Builder

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

```
public Builder ()
```

Default constructor

<br />

### Builder

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

```
public Builder (PictureInPictureParams original)
```

Copy constructor

<br />

| Parameters ||
|---|---|
| `original` | `PictureInPictureParams`: `https://developer.android.com/reference/android/app/PictureInPictureParams` instance this builder is built upon. This value cannot be `null`. <br /> |

## Public methods

### build

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

```
public PictureInPictureParams build ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PictureInPictureParams` | an immutable `https://developer.android.com/reference/android/app/PictureInPictureParams` to be used when entering or updating the activity in picture-in-picture. <br /> |

**See also:**

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

### setActions

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public PictureInPictureParams.Builder setActions (List<RemoteAction> actions, 
                RemoteAction primaryAction)
```

Sets the user actions and a primary action. If there are more than
`https://developer.android.com/reference/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.

<br />

<br />

| Parameters ||
|---|---|
| `actions` | `List`: the new actions to show in the picture-in-picture menu. This value may be `null`. <br /> |
| `primaryAction` | `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`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | this builder instance. This value cannot be `null`. <br /> |

**See also:**

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

### setActions

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

```
public PictureInPictureParams.Builder setActions (List<RemoteAction> actions)
```

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

<br />

| Parameters ||
|---|---|
| `actions` | `List`: the new actions to show in the picture-in-picture menu. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | this builder instance. <br /> |

**See also:**

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

### setAspectRatio

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

```
public PictureInPictureParams.Builder setAspectRatio (Rational aspectRatio)
```

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

<br />

| Parameters ||
|---|---|
| `aspectRatio` | `Rational`: the new aspect ratio for the activity in picture-in-picture, must be between 2.39:1 and 1:2.39 (inclusive). <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | this builder instance. <br /> |

### setAutoEnterEnabled

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

```
public PictureInPictureParams.Builder setAutoEnterEnabled (boolean autoEnterEnabled)
```

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/android/app/Activity#enterPictureInPictureMode(android.app.PictureInPictureParams)`.

If true, `https://developer.android.com/reference/android/app/Activity#onPictureInPictureRequested()` will never be called.

This property is `false` by default.

<br />

| Parameters ||
|---|---|
| `autoEnterEnabled` | `boolean`: `true` if the system will automatically put the activity in picture-in-picture mode. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | this builder instance. This value cannot be `null`. <br /> |

### setCloseAction

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

```
public PictureInPictureParams.Builder setCloseAction (RemoteAction action)
```

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#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/android/app/PictureInPictureParams.Builder#setActions(java.util.List<android.app.RemoteAction>)`
it may be shown in place of that custom action in the menu.

<br />

| Parameters ||
|---|---|
| `action` | `RemoteAction`: to replace the system close action. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | this builder instance. This value cannot be `null`. <br /> |

**See also:**

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

### setExpandedAspectRatio

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

```
public PictureInPictureParams.Builder setExpandedAspectRatio (Rational expandedAspectRatio)
```

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

<br />

| Parameters ||
|---|---|
| `expandedAspectRatio` | `Rational`: must not be between 2.39:1 and 1:2.39 (inclusive). If `null`, expanded picture-in-picture mode is not supported. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | this builder instance. This value cannot be `null`. <br /> |

### setOverlayActions

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public PictureInPictureParams.Builder setOverlayActions (List<RemoteAction> overlayActions, 
                RemoteAction primaryOverlayAction)
```

Sets the overlay actions and a primary overlay action. If there are more than
`https://developer.android.com/reference/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/android/app/PictureInPictureParams.Builder#setActions(java.util.List<android.app.RemoteAction>)`, these actions are
rendered prominently as an overlay and are visible without requiring the user to tap
on the window to reveal the menu.

<br />

| Parameters ||
|---|---|
| `overlayActions` | `List`: 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`. <br /> |
| `primaryOverlayAction` | `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`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | this builder instance. This value cannot be `null`. <br /> |

**See also:**

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

### setSeamlessResizeEnabled

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

```
public PictureInPictureParams.Builder setSeamlessResizeEnabled (boolean seamlessResizeEnabled)
```

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.

<br />

| Parameters ||
|---|---|
| `seamlessResizeEnabled` | `boolean`: `true` if the system can seamlessly resize the window while activity is in picture-in-picture mode. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | this builder instance. This value cannot be `null`. <br /> |

### setSourceRectHint

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

```
public PictureInPictureParams.Builder setSourceRectHint (Rect launchBounds)
```

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.

<br />

| Parameters ||
|---|---|
| `launchBounds` | `Rect`: 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) <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | this builder instance. <br /> |

### setSubtitle

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

```
public PictureInPictureParams.Builder setSubtitle (CharSequence subtitle)
```

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/android/app/PictureInPictureParams.Builder#setTitle(java.lang.CharSequence)` should
be prioritized.

Subtitles longer than 1024 characters (default) are automatically truncated.

<br />

| Parameters ||
|---|---|
| `subtitle` | `CharSequence`: Details about the PIP content. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | this builder instance. This value cannot be `null`. <br /> |

### setTitle

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

```
public PictureInPictureParams.Builder setTitle (CharSequence title)
```

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.

<br />

| Parameters ||
|---|---|
| `title` | `CharSequence`: General information about the PIP content. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder` | this builder instance. This value cannot be `null`. <br /> |