EmbeddedPhotoPickerProvider


interface EmbeddedPhotoPickerProvider
android.widget.photopicker.EmbeddedPhotoPickerProvider

This interface provides an api that callers can use to get a session of embedded PhotoPicker (EmbeddedPhotoPickerSession).

Callers can get instance of this class using EmbeddedPhotoPickerProviderFactory.create(Context).

Under the hood, a service connection with photopicker is established by the implementation of this api. To help establish this connection, a caller must include in their Manifest:

<code>&lt;queries&gt;
    &lt;intent&gt;
        &lt;action android:name="com.android.photopicker.core.embedded.EmbeddedService.BIND"/&gt;
    &lt;/intent&gt;
  &lt;/queries&gt;
  </code>

When a session opens successfully, they would receive an instance of EmbeddedPhotoPickerSession and android.view.SurfaceControlViewHost.SurfacePackage via the api

Callers pass an instance of EmbeddedPhotoPickerClient which is used by service to notify about different events (like sessionError, uri granted/revoked etc) to them. One-to-one relationship of client to session must be maintained by a caller i.e. they shouldn't reuse same callback for more than one openSession requests.

The EmbeddedPhotoPickerSession instance can be used to notify photopicker about different events (like resize, configChange etc).

This api is supported on api versions Android U+.

Summary

Public methods
abstract Unit
openSession(hostToken: IBinder, displayId: Int, width: Int, height: Int, featureInfo: EmbeddedPhotoPickerFeatureInfo, clientExecutor: Executor, callback: EmbeddedPhotoPickerClient)

Open a new session for displaying content with an initial size of width x height pixels.

Public methods

openSession

abstract fun openSession(
    hostToken: IBinder,
    displayId: Int,
    width: Int,
    height: Int,
    featureInfo: EmbeddedPhotoPickerFeatureInfo,
    clientExecutor: Executor,
    callback: EmbeddedPhotoPickerClient
): Unit

Open a new session for displaying content with an initial size of width x height pixels. EmbeddedPhotoPickerClient will receive all incoming communication from the PhotoPicker. All incoming calls to EmbeddedPhotoPickerClient will be made through the provided clientExecutor

Parameters
hostToken IBinder: Token used for constructing android.view.SurfaceControlViewHost. Use AttachedSurfaceControl.getInputTransferToken() to get token of attached android.view.SurfaceControlViewHost.SurfacePackage. This value cannot be null.
displayId Int: Application display id. Use DisplayManager.getDisplays() to get the id.
width Int: width of the view, in pixels.
height Int: height of the view, in pixels.
featureInfo EmbeddedPhotoPickerFeatureInfo: EmbeddedPhotoPickerFeatureInfo object containing all the required features for the given session. This value cannot be null.
clientExecutor Executor: Executor to invoke callbacks. This value cannot be null.
callback EmbeddedPhotoPickerClient: EmbeddedPhotoPickerClient object to receive callbacks from photopicker. This value cannot be null.