rememberCaptureMediaLauncher
fun rememberCaptureMediaLauncher(photo: Boolean, video: Boolean, onResult: (File) -> Unit): ManagedActivityResultLauncher<Unit, File?>?
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
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)
Content copied to clipboard
Note: This function doesn't check for camera permissions. Ensure that the necessary permissions are granted before invoking the launcher.