Builder
class Builder
kotlin.Any | |
↳ | android.app.PictureInPictureParams.Builder |
Builder class for PictureInPictureParams
objects.
Summary
Public constructors | |
---|---|
Builder() Default constructor |
|
Builder(original: PictureInPictureParams) Copy constructor |
Public methods | |
---|---|
open PictureInPictureParams! |
build() |
open PictureInPictureParams.Builder! |
setActions(actions: MutableList<RemoteAction!>!) Sets the user actions. |
open PictureInPictureParams.Builder! |
setAspectRatio(aspectRatio: Rational!) Sets the aspect ratio. |
open PictureInPictureParams.Builder |
setAutoEnterEnabled(autoEnterEnabled: Boolean) Sets whether the system will automatically put the activity in picture-in-picture mode without needing/waiting for the activity to call |
open PictureInPictureParams.Builder |
setCloseAction(action: RemoteAction?) Sets a close action that should be invoked before the default close PiP action. |
open PictureInPictureParams.Builder |
setExpandedAspectRatio(expandedAspectRatio: Rational?) Sets the aspect ratio for the expanded picture-in-picture mode. |
open PictureInPictureParams.Builder |
setSeamlessResizeEnabled(seamlessResizeEnabled: Boolean) Sets whether the system can seamlessly resize the window while the activity is in picture-in-picture mode. |
open PictureInPictureParams.Builder! |
setSourceRectHint(launchBounds: Rect!) Sets the window-coordinate bounds of an activity transitioning to picture-in-picture. |
open PictureInPictureParams.Builder |
setSubtitle(subtitle: CharSequence?) 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 |
setTitle(title: CharSequence?) 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
Builder(original: PictureInPictureParams)
Copy constructor
Parameters | |
---|---|
original |
PictureInPictureParams: PictureInPictureParams instance this builder is built upon. This value cannot be null . |
Public methods
build
open fun build(): PictureInPictureParams!
Return | |
---|---|
PictureInPictureParams! |
an immutable PictureInPictureParams to be used when entering or updating the activity in picture-in-picture. |
setActions
open fun setActions(actions: MutableList<RemoteAction!>!): PictureInPictureParams.Builder!
Sets the user actions. If there are more than Activity#getMaxNumPictureInPictureActions()
actions, then the input list will be truncated to that number.
Parameters | |
---|---|
actions |
MutableList<RemoteAction!>!: the new actions to show in the picture-in-picture menu. |
Return | |
---|---|
PictureInPictureParams.Builder! |
this builder instance. |
See Also
setAspectRatio
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!: the new aspect ratio for the activity in picture-in-picture, must be between 2.39:1 and 1:2.39 (inclusive). |
Return | |
---|---|
PictureInPictureParams.Builder! |
this builder instance. |
setAutoEnterEnabled
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 Activity#enterPictureInPictureMode(PictureInPictureParams)
. If true, Activity#onPictureInPictureRequested()
will never be called. This property is false
by default.
Parameters | |
---|---|
autoEnterEnabled |
Boolean: true if the system will automatically put the activity in picture-in-picture mode. |
Return | |
---|---|
PictureInPictureParams.Builder |
this builder instance. This value cannot be null . |
setCloseAction
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 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 PictureInPictureParams.Builder#setActions(List)
it may be shown in place of that custom action in the menu.
Parameters | |
---|---|
action |
RemoteAction?: to replace the system close action This value may be null . |
Return | |
---|---|
PictureInPictureParams.Builder |
this builder instance. This value cannot be null . |
See Also
setExpandedAspectRatio
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 PackageManager#FEATURE_EXPANDED_PICTURE_IN_PICTURE
feature which can be detected using PackageManager.hasSystemFeature(String)
.
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. |
Return | |
---|---|
PictureInPictureParams.Builder |
this builder instance. This value cannot be null . |
setSeamlessResizeEnabled
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: true if the system can seamlessly resize the window while activity is in picture-in-picture mode. |
Return | |
---|---|
PictureInPictureParams.Builder |
this builder instance. This value cannot be null . |
setSourceRectHint
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 for more details.
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) |
Return | |
---|---|
PictureInPictureParams.Builder! |
this builder instance. |
setSubtitle
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 PictureInPictureParams.Builder#setTitle(CharSequence)
should be prioritized.
Parameters | |
---|---|
subtitle |
CharSequence?: Details about the PIP content. This value may be null . |
Return | |
---|---|
PictureInPictureParams.Builder |
this builder instance This value cannot be null . |
setTitle
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.
Parameters | |
---|---|
title |
CharSequence?: General information about the PIP content This value may be null . |
Return | |
---|---|
PictureInPictureParams.Builder |
this builder instance. This value cannot be null . |