# EmbeddedPhotoPickerState

Artifact: [androidx.photopicker:photopicker-compose](https://developer.android.com/jetpack/androidx/releases/photopicker) [View Source](https://cs.android.com/search?q=file:androidx/photopicker/compose/EmbeddedPhotoPickerState.kt+class:androidx.photopicker.compose.EmbeddedPhotoPickerState) Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)


```
@RequiresApi(value = 34)
@ExperimentalPhotoPickerComposeApi
interface EmbeddedPhotoPickerState
```

<br />

*** ** * ** ***

State model of a EmbeddedPhotoPickerSession. This interface models the state and session management lifecycle of the Embedded Photopicker between the client application and the remote service.

A default implementation is provided via the `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/rememberEmbeddedPhotoPickerState.composable#rememberEmbeddedPhotoPickerState(kotlin.Array,kotlin.Boolean,kotlin.collections.Set,kotlin.Function1,kotlin.Function1,kotlin.Function1,kotlin.Function0)` composable which can be used to obtain an implementation that should work for most use cases. This object can be passed to the `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPicker.composable#EmbeddedPhotoPicker(androidx.photopicker.compose.EmbeddedPhotoPickerState,androidx.compose.ui.Modifier,android.widget.photopicker.EmbeddedPhotoPickerProvider,android.widget.photopicker.EmbeddedPhotoPickerFeatureInfo)` composable which provides the display layer for the Embedded PhotoPicker.

Callbacks to the underlying session are exposed here to push Compose state into the remote view.

## Summary

| ### Public functions |
|---|---|
| `open suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#deselectUri(android.net.Uri)(uri: https://developer.android.com/reference/android/net/Uri.html)` Request the EmbeddedPhotoPickerSession deselect the media item with the provided Uri. |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#deselectUris(kotlin.collections.List)(uris: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/net/Uri.html>)` Request the EmbeddedPhotoPickerSession deselect media items with the provided list of Uris from its interface. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#notifyConfigurationChanged(android.content.res.Configuration)(config: https://developer.android.com/reference/android/content/res/Configuration.html)` Notify the underlying `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` that the current `https://developer.android.com/reference/android/content/res/Configuration.html` has changed. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#notifyResized(androidx.compose.ui.unit.IntSize)(size: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize)` Notify the underlying `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` that its parent view has been resized. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#onSelectionComplete()()` Receiver for when the user is done with their selection and the picker should be collapsed. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#onSessionError(kotlin.Throwable)(throwable: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html)` Receiver for when the Photopicker Session encounters a terminal error. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#onUriPermissionGranted(kotlin.collections.List)(uris: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/net/Uri.html>)` Receiver for when URI permission has been granted to item(s) selected by the user. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#onUriPermissionRevoked(kotlin.collections.List)(uris: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/net/Uri.html>)` Receiver for when URI permission has been revoked of an item deselected by the user. |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresExtension(extension = 34, version = 15) https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#runSession(android.widget.photopicker.EmbeddedPhotoPickerProvider,android.widget.photopicker.EmbeddedPhotoPickerFeatureInfo,kotlin.Function1)( provider: https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerProvider.html, featureInfo: https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerFeatureInfo.html, onReceiveSession: (https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Run a `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` using the state provided by this state object. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#isExpanded()` The current expanded state of this state object. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#isReadyToRunSession()` The current ready state of this state object. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/android/net/Uri.html>` | `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#selectedMedia()` A read-only set of URIs representing the currently selected media items. |
| `https://developer.android.com/reference/android/os/IBinder.html?` | `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#surfaceHostToken()` The host token for the `SurfaceControlViewHost` where the picker UI will be rendered. |

## Public functions

### deselectUri

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
open suspend fun deselectUri(uri: Uri): Unit
```

Request the EmbeddedPhotoPickerSession deselect the media item with the provided Uri.

NOTE: The Uri should have been received from the PhotoPicker. Regular `https://developer.android.com/reference/android/provider/MediaStore.html` uris, or other Uris passed here will be ignored by the Photopicker.

| Parameters |
|---|---|
| `uri: https://developer.android.com/reference/android/net/Uri.html` | the `https://developer.android.com/reference/android/net/Uri.html` that should be deselected in the PhotoPicker's interface. |

### deselectUris

```
suspend fun deselectUris(uris: List<Uri>): Unit
```

Request the EmbeddedPhotoPickerSession deselect media items with the provided list of Uris from its interface.

NOTE: The Uri should have been received from the PhotoPicker. Regular `https://developer.android.com/reference/android/provider/MediaStore.html` uris, or other Uris passed here will be ignored by the PhotoPicker.

| Parameters |
|---|---|
| `uris: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/net/Uri.html>` | the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html` of `https://developer.android.com/reference/android/net/Uri.html` that should be deselected in the PhotoPicker's interface. |

### notifyConfigurationChanged

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
fun notifyConfigurationChanged(config: Configuration): Unit
```

Notify the underlying `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` that the current `https://developer.android.com/reference/android/content/res/Configuration.html` has changed.

### notifyResized

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
fun notifyResized(size: IntSize): Unit
```

Notify the underlying `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` that its parent view has been resized.

| Parameters |
|---|---|
| `size: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize` | The new size of the parent view. |

### onSelectionComplete

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
fun onSelectionComplete(): Unit
```

Receiver for when the user is done with their selection and the picker should be collapsed.

| See also |
|---|---|
| `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerClient.html` | #onSelectionComplete |

### onSessionError

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
fun onSessionError(throwable: Throwable): Unit
```

Receiver for when the Photopicker Session encounters a terminal error.

| See also |
|---|---|
| `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerClient.html` | #onSessionError |

### onUriPermissionGranted

```
fun onUriPermissionGranted(uris: List<Uri>): Unit
```

Receiver for when URI permission has been granted to item(s) selected by the user.

| See also |
|---|---|
| `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerClient.html` | #onUriPermissionGranted |

### onUriPermissionRevoked

```
fun onUriPermissionRevoked(uris: List<Uri>): Unit
```

Receiver for when URI permission has been revoked of an item deselected by the user.

| See also |
|---|---|
| `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerClient.html` | #onUriPermissionRevoked |

### runSession

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
@RequiresExtension(extension = 34, version = 15)
suspend fun runSession(
    provider: EmbeddedPhotoPickerProvider,
    featureInfo: EmbeddedPhotoPickerFeatureInfo,
    onReceiveSession: (EmbeddedPhotoPickerSession) -> Unit
): Unit
```

Run a `https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html` using the state provided by this state object.

This suspended function should be started from a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/LaunchedEffect.composable#LaunchedEffect(kotlin.coroutines.SuspendFunction1)` in the composable hosting the SurfaceView the `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPicker.composable#EmbeddedPhotoPicker(androidx.photopicker.compose.EmbeddedPhotoPickerState,androidx.compose.ui.Modifier,android.widget.photopicker.EmbeddedPhotoPickerProvider,android.widget.photopicker.EmbeddedPhotoPickerFeatureInfo)` is drawing to. The function should perform the necessary startup logic with the EmbeddedPhotoPickerProvider, and then run the provided client in a child scope of the current CoroutineScope. Throughout the entire session, and then close / cleanup any resources being used when the suspended function is cancelled.

| Parameters |
|---|---|
| `provider: https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerProvider.html` | The provider that should be used for this session. |
| `featureInfo: https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerFeatureInfo.html` | The client provided EmbeddedPhotoPickerFeatureInfo to configure the Embedded PhotoPicker. |
| `onReceiveSession: (https://developer.android.com/reference/android/widget/photopicker/EmbeddedPhotoPickerSession.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | A callback from the display layer, which can be used to pass the opened Session back to the display layer so it can be attached to the SurfaceView. |

## Public properties

### isExpanded

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
var isExpanded: Boolean
```

The current expanded state of this state object. Signifies whether the underlying EmbeddedPhotopicker session is expanded or collapsed.

### isReadyToRunSession

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
val isReadyToRunSession: Boolean
```

The current ready state of this state object. Signifies that the Compose host is ready, which allows the display layer Composable to call `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#runSession(android.widget.photopicker.EmbeddedPhotoPickerProvider,android.widget.photopicker.EmbeddedPhotoPickerFeatureInfo,kotlin.Function1)`.

### selectedMedia

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
val selectedMedia: Set<Uri>
```

A read-only set of URIs representing the currently selected media items. Updated internally based on granted/revoked permissions.

### surfaceHostToken

Added in [1.0.0-alpha02](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha02)

```
var surfaceHostToken: IBinder?
```

The host token for the `SurfaceControlViewHost` where the picker UI will be rendered. Set externally before `https://developer.android.com/reference/kotlin/androidx/photopicker/compose/EmbeddedPhotoPickerState#runSession(android.widget.photopicker.EmbeddedPhotoPickerProvider,android.widget.photopicker.EmbeddedPhotoPickerFeatureInfo,kotlin.Function1)` is called.