rememberCaptureMediaLauncher

Creates and remembers a launcher for capturing media (photo and/or video) using the device camera.

Return

A ManagedActivityResultLauncher that can be used to launch the media capture activity, or null if both photo and video are false (no valid capture mode). The launcher accepts Unit as input and produces a nullable File as output.

Parameters

photo

If true, enables photo capture capability. When both photo and video are true, the user will be able to capture both types of media.

video

If true, enables video capture capability. When both photo and video are true, the user will be able to capture both types of media.

onResult

Callback invoked when media capture completes successfully. Receives a File representing the captured media. This callback is only invoked if the user successfully captures media; it is not called if the user cancels the capture.

See also

Example usage:

val captureMediaLauncher = rememberCaptureMediaLauncher(
photo = true,
video = true,
onResult = { file ->
// Handle captured media file
}
)

// Launch the camera
captureMediaLauncher?.launch(Unit)

Note: This function doesn't check for camera permissions. Ensure that the necessary permissions are granted before invoking the launcher.