Stay organized with collections
Save and categorize content based on your preferences.
EmbeddedPhotoPickerProvider
public
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:
<queries>
<intent>
<action android:name="com.android.photopicker.core.embedded.EmbeddedService.BIND"/>
</intent>
</queries>
When a session opens successfully, they would receive an instance of
EmbeddedPhotoPickerSession
and 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
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-03-13 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-13 UTC."],[],[],null,["# EmbeddedPhotoPickerProvider\n\nAdded in [API level 36](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nAlso in [U Extensions 15](/sdkExtensions) \n\nEmbeddedPhotoPickerProvider\n===========================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/widget/photopicker/EmbeddedPhotoPickerProvider \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\n\n\ninterface\nEmbeddedPhotoPickerProvider\n`\n\n\n`\n\n\n`\n\n|--------------------------------------------------------|\n| android.widget.photopicker.EmbeddedPhotoPickerProvider |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nThis interface provides an api that callers can use to get a session of embedded PhotoPicker\n([EmbeddedPhotoPickerSession](/reference/android/widget/photopicker/EmbeddedPhotoPickerSession)).\n\nCallers can get instance of this class using\n[EmbeddedPhotoPickerProviderFactory.create(Context)](/reference/android/widget/photopicker/EmbeddedPhotoPickerProviderFactory#create(android.content.Context)).\n\nUnder the hood, a service connection with photopicker is established by the implementation\nof this api. To help establish this connection, a caller must include in their Manifest: \n\n \u003cqueries\u003e\n \u003cintent\u003e\n \u003caction android:name=\"com.android.photopicker.core.embedded.EmbeddedService.BIND\"/\u003e\n \u003c/intent\u003e\n \u003c/queries\u003e\n \nWhen a session opens successfully, they would receive an instance of\n[EmbeddedPhotoPickerSession](/reference/android/widget/photopicker/EmbeddedPhotoPickerSession) and [SurfaceControlViewHost.SurfacePackage](/reference/android/view/SurfaceControlViewHost.SurfacePackage)\nvia the [api](/reference/android/widget/photopicker/EmbeddedPhotoPickerClient#onSessionOpened(android.widget.photopicker.EmbeddedPhotoPickerSession))\n\nCallers pass an instance of [EmbeddedPhotoPickerClient](/reference/android/widget/photopicker/EmbeddedPhotoPickerClient) which is used by service to\nnotify about different events (like sessionError, uri granted/revoked etc) to them.\nOne-to-one relationship of client to session must be maintained by a caller i.e. they shouldn't\nreuse same callback for more than one openSession requests.\n\nThe [EmbeddedPhotoPickerSession](/reference/android/widget/photopicker/EmbeddedPhotoPickerSession) instance can be used to notify photopicker about\ndifferent events (like resize, configChange etc).\n\nThis api is supported on api versions Android U+. \n**See also:**\n\n- [EmbeddedPhotoPickerClient](/reference/android/widget/photopicker/EmbeddedPhotoPickerClient)\n- [EmbeddedPhotoPickerSession](/reference/android/widget/photopicker/EmbeddedPhotoPickerSession)\n- [todo(b/358513325): Move this to new package when its ready](/reference/android/widget/photopicker/EmbeddedPhotoPickerProviderFactory)\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[openSession](/reference/android/widget/photopicker/EmbeddedPhotoPickerProvider#openSession(android.os.IBinder,%20int,%20int,%20int,%20android.widget.photopicker.EmbeddedPhotoPickerFeatureInfo,%20java.util.concurrent.Executor,%20android.widget.photopicker.EmbeddedPhotoPickerClient))`(`[IBinder](/reference/android/os/IBinder)` hostToken, int displayId, int width, int height, `[EmbeddedPhotoPickerFeatureInfo](/reference/android/widget/photopicker/EmbeddedPhotoPickerFeatureInfo)` featureInfo, `[Executor](/reference/java/util/concurrent/Executor)` clientExecutor, `[EmbeddedPhotoPickerClient](/reference/android/widget/photopicker/EmbeddedPhotoPickerClient)` callback) ` Open a new session for displaying content with an initial size of width x height pixels. |\n\nPublic methods\n--------------\n\n### openSession\n\nAdded in [API level 36](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nAlso in [U Extensions 15](/sdkExtensions) \n\n```\npublic abstract void openSession (IBinder hostToken, \n int displayId, \n int width, \n int height, \n EmbeddedPhotoPickerFeatureInfo featureInfo, \n Executor clientExecutor, \n EmbeddedPhotoPickerClient callback)\n```\n\nOpen a new session for displaying content with an initial size of\nwidth x height pixels. [EmbeddedPhotoPickerClient](/reference/android/widget/photopicker/EmbeddedPhotoPickerClient) will receive all incoming\ncommunication from the PhotoPicker. All incoming calls to [EmbeddedPhotoPickerClient](/reference/android/widget/photopicker/EmbeddedPhotoPickerClient)\nwill be made through the provided `clientExecutor`\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `hostToken` | `IBinder`: Token used for constructing [SurfaceControlViewHost](/reference/android/view/SurfaceControlViewHost). Use [AttachedSurfaceControl.getInputTransferToken()](/reference/android/view/AttachedSurfaceControl#getInputTransferToken()) to get token of attached [SurfaceControlViewHost.SurfacePackage](/reference/android/view/SurfaceControlViewHost.SurfacePackage). This value cannot be `null`. \u003cbr /\u003e |\n| `displayId` | `int`: Application display id. Use [DisplayManager.getDisplays()](/reference/android/hardware/display/DisplayManager#getDisplays()) to get the id. \u003cbr /\u003e |\n| `width` | `int`: width of the view, in pixels. \u003cbr /\u003e |\n| `height` | `int`: height of the view, in pixels. \u003cbr /\u003e |\n| `featureInfo` | `EmbeddedPhotoPickerFeatureInfo`: [EmbeddedPhotoPickerFeatureInfo](/reference/android/widget/photopicker/EmbeddedPhotoPickerFeatureInfo) object containing all the required features for the given session. This value cannot be `null`. \u003cbr /\u003e |\n| `clientExecutor` | `Executor`: [Executor](/reference/java/util/concurrent/Executor) to invoke callbacks. This value cannot be `null`. \u003cbr /\u003e |\n| `callback` | `EmbeddedPhotoPickerClient`: [EmbeddedPhotoPickerClient](/reference/android/widget/photopicker/EmbeddedPhotoPickerClient) object to receive callbacks from photopicker. This value cannot be `null`. \u003cbr /\u003e |"]]