CaptureMediaContract

class CaptureMediaContract(mode: CaptureMediaContract.Mode, fileManager: StreamFileManager = StreamFileManager(), pictureFile: File? = null, videoFile: File? = null) : ActivityResultContract<Unit, File?>

Activity result contract for capturing media (photos and/or videos) using the device camera.

Files are created in external storage directories:

  • Photos: {externalFilesDir}/Pictures/

  • Videos: {externalFilesDir}/Movies/ With fallback to cache directories if external storage is unavailable.

After createIntent the caller should persist pictureFile and videoFile paths so they can be restored after process death via the constructor.

Parameters

mode

The capture mode determining what media types can be captured.

fileManager

Manager for creating temporary files in external storage.

pictureFile

Previously created photo file to restore after process death.

videoFile

Previously created video file to restore after process death.

Constructors

Link copied to clipboard
constructor(mode: CaptureMediaContract.Mode, fileManager: StreamFileManager = StreamFileManager(), pictureFile: File? = null, videoFile: File? = null)

Types

Link copied to clipboard

Properties

Link copied to clipboard

The photo destination file created by createIntent, or restored via constructor.

Link copied to clipboard

The video destination file created by createIntent, or restored via constructor.

Functions

Link copied to clipboard
open override fun createIntent(context: Context, input: Unit): Intent
Link copied to clipboard
open override fun parseResult(resultCode: Int, intent: Intent?): File?