Added in API level 31

PictureInPictureUiState


class PictureInPictureUiState : Parcelable
kotlin.Any
   ↳ android.app.PictureInPictureUiState

Used by Activity.onPictureInPictureUiStateChanged(PictureInPictureUiState).

Summary

Inherited constants
Public methods
Int

Boolean
equals(other: Any?)

Int

Boolean

Returns whether Picture-in-Picture is stashed or not.

Boolean

Returns true if the app is going to enter Picture-in-Picture (PiP) mode.

Unit
writeToParcel(out: Parcel, flags: Int)

Flatten this object in to a Parcel.

Properties
static Parcelable.Creator<PictureInPictureUiState!>

Public methods

describeContents

Added in API level 31
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 31
fun equals(other: Any?): Boolean
Parameters
obj the reference object with which to compare.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

hashCode

Added in API level 31
fun hashCode(): Int
Return
Int a hash code value for this object.

isStashed

Added in API level 31
fun isStashed(): Boolean

Returns whether Picture-in-Picture is stashed or not. A stashed PiP means it is only partially visible to the user, with some parts of it being off-screen. This is usually a UI state that is triggered by the user, such as flinging the PiP to the edge or letting go of PiP while dragging partially off-screen. Developers can use this in conjunction with Activity.onPictureInPictureUiStateChanged(PictureInPictureUiState) to get a signal when the PiP stash state has changed. For example, if the state changed from false to true, developers can choose to temporarily pause video playback if PiP is of video content. Vice versa, if changing from true to false and video content is paused, developers can resume video playback.

See Also

    isTransitioningToPip

    Added in API level 35
    fun isTransitioningToPip(): Boolean

    Returns true if the app is going to enter Picture-in-Picture (PiP) mode. This state is associated with the entering PiP animation. When that animation starts, whether via auto enter PiP or calling Activity.enterPictureInPictureMode(PictureInPictureParams) explicitly, app can expect Activity.onPictureInPictureUiStateChanged(PictureInPictureUiState) callback with isTransitioningToPip() to be true first, followed by Activity.onPictureInPictureModeChanged(boolean, Configuration) when it fully settles in PiP mode. When app receives the Activity.onPictureInPictureUiStateChanged(PictureInPictureUiState) callback with isTransitioningToPip() being true, it's recommended to hide certain UI elements, such as video controls, to archive a clean entering PiP animation. In case an application wants to restore the previously hidden UI elements when exiting PiP, it is recommended to do that in onPictureInPictureModeChanged(isInPictureInPictureMode=false) callback rather than the beginning of exit PiP animation.

    writeToParcel

    Added in API level 31
    fun writeToParcel(
        out: Parcel,
        flags: Int
    ): Unit

    Flatten this object in to a Parcel.

    Parameters
    dest The Parcel in which the object should be written. This value cannot be null.
    flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES
    out Parcel: This value cannot be null.

    Properties

    CREATOR

    Added in API level 31
    static val CREATOR: Parcelable.Creator<PictureInPictureUiState!>