ContentPipCallback


public interface ContentPipCallback


A callback interface for managing the handoff of a content between the main activity and the Content PiP.

After registering ContentPipCallback via enablePipOnAppSwitch, application can expect the callbacks in the following order

  1. onInitContentPip, app can return the PiP eligibility

  2. onPrepareContentPip, app prepares for the handoff

  3. onAttachContentPip, app attaches the content to the new Activity (that will enter PiP)

  4. onFinishContentPip, app is notified that content PiP is finished

Summary

Public methods

abstract void

Called once the proxy PiP Activity is ready.

abstract void
onFinishContentPip(boolean isDismissed)

Called when the PiP task is finishing or the enter PiP attempt is failed.

abstract boolean

Called before attempting to start the Content PiP solution.

abstract boolean

Called on the main Activity to prepare for the handoff (e.g., detaching a Player from its View).

Public methods

onAttachContentPip

Added in 1.0.0-alpha04
abstract void onAttachContentPip(@NonNull ComponentActivity pipActivity)

Called once the proxy PiP Activity is ready. The app should attach its content (e.g., a Player) to this new pipActivity.

Parameters
@NonNull ComponentActivity pipActivity

The new Activity serving as the PiP container.

onFinishContentPip

Added in 1.0.0-alpha04
abstract void onFinishContentPip(boolean isDismissed)

Called when the PiP task is finishing or the enter PiP attempt is failed.

For instance, a video app can use isDismissed to determine if it needs to stop playback. This is true when the user dismisses or closes the PiP, and false when the user expands the PiP to full-screen mode.

Parameters
boolean isDismissed

whether the PiP task is explicitly dismissed by the user.

onInitContentPip

Added in 1.0.0-alpha04
abstract boolean onInitContentPip()

Called before attempting to start the Content PiP solution.

Returns
boolean

true if the application is eligible to enter PiP. If false is returned, the PiP flow is canceled.

onPrepareContentPip

Added in 1.0.0-alpha04
abstract boolean onPrepareContentPip()

Called on the main Activity to prepare for the handoff (e.g., detaching a Player from its View).

Returns
boolean

true if the handoff is successful on the main Activity. If false is returned, the PiP flow is canceled.