rememberEmbeddedPhotoPickerState

Functions summary

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

Generates a EmbeddedPhotoPickerState object and remembers it.

Functions

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 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 androidx.compose.runtime.key block. For example:

key(userId) {
rememberEmbeddedPhotoPickerState()
}
Parameters
initialExpandedValue: Boolean = false

the initial expanded state of the photopicker. This property only affects the initial value, and has no further effect.

initialMediaSelection: Set<Uri> = 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: (Throwable) -> Unit = {}

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: (List<Uri>) -> Unit = {}

Called when the user has selected media items in the embedded photo picker.

onUriPermissionRevoked: (List<Uri>) -> Unit = {}

Called when the user has deselected media items in the embedded photo picker.

onSelectionComplete: () -> Unit = {}

Called when the user is done with their selection and the app should collapse or close the PhotoPicker.

Returns
EmbeddedPhotoPickerState

state object for interacting with an EmbeddedPhotoPickerSession.