PictureInPictureParams.Builder | API reference | Android Developers (original) (raw)
public static class PictureInPictureParams.Builder
extends [Object](/reference/java/lang/Object)
``
Builder class for [PictureInPictureParams](/reference/android/app/PictureInPictureParams)
objects.
Summary
Public constructors |
---|
Builder() Default constructor |
Builder(PictureInPictureParams original) Copy constructor |
Public methods | |
---|---|
PictureInPictureParams | build() |
PictureInPictureParams.Builder | setActions(List<RemoteAction> actions) Sets the user actions. |
PictureInPictureParams.Builder | setAspectRatio(Rational aspectRatio) Sets the aspect ratio. |
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 callActivity.enterPictureInPictureMode(PictureInPictureParams). |
PictureInPictureParams.Builder | setCloseAction(RemoteAction action) Sets a close action that should be invoked before the default close PiP action. |
PictureInPictureParams.Builder | setExpandedAspectRatio(Rational expandedAspectRatio) Sets the aspect ratio for the expanded picture-in-picture mode. |
PictureInPictureParams.Builder | setSeamlessResizeEnabled(boolean seamlessResizeEnabled) Sets whether the system can seamlessly resize the window while the activity is in picture-in-picture mode. |
PictureInPictureParams.Builder | setSourceRectHint(Rect launchBounds) Sets the window-coordinate bounds of an activity transitioning to picture-in-picture. |
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. |
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. |
Inherited methods |
---|
From class java.lang.Object Object clone() Creates and returns a copy of this object. boolean equals(Object obj) Indicates whether some other object is "equal to" this one. void finalize() Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. finalClass<?> getClass() Returns the runtime class of this Object. int hashCode() Returns a hash code value for the object. final void notify() Wakes up a single thread that is waiting on this object's monitor. final void notifyAll() Wakes up all threads that are waiting on this object's monitor. String toString() Returns a string representation of the object. final void wait(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 wait(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 wait() Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
Public constructors
Builder
public Builder ()
Default constructor
Public methods
setAspectRatio
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.
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). |
Returns | |
---|---|
PictureInPictureParams.Builder | this builder instance. |
setExpandedAspectRatio
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 [PackageManager#FEATURE_EXPANDED_PICTURE_IN_PICTURE](/reference/android/content/pm/PackageManager#FEATURE%5FEXPANDED%5FPICTURE%5FIN%5FPICTURE)
feature which can be detected using [PackageManager.hasSystemFeature(String)](/reference/android/content/pm/PackageManager#hasSystemFeature%28java.lang.String%29)
.
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. |
Returns | |
---|---|
PictureInPictureParams.Builder | this builder instance. This value cannot be null. |
setSeamlessResizeEnabled
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.
Parameters | |
---|---|
seamlessResizeEnabled | boolean: true if the system can seamlessly resize the window while activity is in picture-in-picture mode. |
Returns | |
---|---|
PictureInPictureParams.Builder | this builder instance. This value cannot be null. |
setSourceRectHint
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. SeeSupport 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) |
Returns | |
---|---|
PictureInPictureParams.Builder | this builder instance. |
setTitle
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.
Parameters | |
---|---|
title | CharSequence: General information about the PIP content This value may be null. |
Returns | |
---|---|
PictureInPictureParams.Builder | this builder instance. This value cannot be null. |