# rememberEmbeddedPhotoPickerState

## Functions summary

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/embedded/compose/EmbeddedPhotoPickerState` | `@https://developer.android.com/reference/kotlin/androidx/photopicker/embedded/compose/ExperimentalPhotoPickerComposeApi @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 34) @https://developer.android.com/reference/kotlin/androidx/annotation/RequiresExtension(extension = 34, version = 15) https://developer.android.com/reference/kotlin/androidx/photopicker/embedded/compose/rememberEmbeddedPhotoPickerState.composable#rememberEmbeddedPhotoPickerState(kotlin.Boolean,kotlin.collections.Set,kotlin.Function1,kotlin.Function1,kotlin.Function1,kotlin.Function0)( initialExpandedValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, initialMediaSelection: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/android/net/Uri.html>, onError: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, onUriPermissionGranted: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/net/Uri.html>) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, onUriPermissionRevoked: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/net/Uri.html>) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, onSelectionComplete: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Generates a `https://developer.android.com/reference/kotlin/androidx/photopicker/embedded/compose/EmbeddedPhotoPickerState` object and remembers it. |

## Functions

### rememberEmbeddedPhotoPickerState

Artifact: [androidx.photopicker:photopicker-embedded-compose](https://developer.android.com/jetpack/androidx/releases/photopicker) [View Source](https://cs.android.com/search?q=file:androidx/photopicker/embedded/compose/EmbeddedPhotoPickerState.kt+function:rememberEmbeddedPhotoPickerState)

```
@ExperimentalPhotoPickerComposeApi
@Composable
@RequiresApi(value = 34)
@RequiresExtension(extension = 34, version = 15)
fun rememberEmbeddedPhotoPickerState(
    initialExpandedValue: Boolean = false,
    initialMediaSelection: Set<Uri> = emptySet<Uri>(),
    onError: (Throwable) -> Unit = {},
    onUriPermissionGranted: (List<Uri>) -> Unit = {},
    onUriPermissionRevoked: (List<Uri>) -> Unit = {},
    onSelectionComplete: () -> Unit = {}
): EmbeddedPhotoPickerState
```

Generates a `https://developer.android.com/reference/kotlin/androidx/photopicker/embedded/compose/EmbeddedPhotoPickerState` object and remembers it. This object can be used to interact with the remote EmbeddedPhotoPickerSession. This object's state will survive the activity or process recreation but the underlying EmbeddedPhotoPickerSession will be recreated along with the activity. (When EmbeddedPhotoPickerState#runSession is next called.)

To reset the state and discard any saved values when certain inputs change, wrap this call in a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/key.composable#key(kotlin.Array,kotlin.Function0)` block. For example:

```kotlin
key(userId) {
    rememberEmbeddedPhotoPickerState()
}
```

| Parameters |
|---|---|
| `initialExpandedValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = false` | the initial expanded state of the photopicker. This property only affects the initial value, and has no further effect. |
| `initialMediaSelection: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/android/net/Uri.html> = emptySet<Uri>()` | the initial set of media that should be selected inside the Photopicker. Note: this should only be URIs that have been given to the calling application by the Photopicker itself, do not pass generic URIs or MediaStore URIs, as they will be ignored. |
| `onError: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html = {}` | Called when an error occurs in the embedded photo picker session. When this occurs, the session cleans up its resources, clears the surface package, and terminates cleanly. Callers should use this callback to update app state, display fallback UI, or prompt the user to retry. |
| `onUriPermissionGranted: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/net/Uri.html>) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html = {}` | Called when the user has selected media items in the embedded photo picker. |
| `onUriPermissionRevoked: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/net/Uri.html>) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html = {}` | Called when the user has deselected media items in the embedded photo picker. |
| `onSelectionComplete: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html = {}` | Called when the user is done with their selection and the app should collapse or close the PhotoPicker. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/embedded/compose/EmbeddedPhotoPickerState` | state object for interacting with an EmbeddedPhotoPickerSession. |