The second Android 11 Developer Preview is now available, test it out and share your feedback.

Builder

class Builder
kotlin.Any
   ↳ androidx.camera.core.ImageCapture.OutputFileOptions.Builder

Builder class for OutputFileOptions.

Summary

Public constructors

<init>(@NonNull file: File)

Creates options to write captured image to a File.

<init>(@NonNull contentResolver: ContentResolver, @NonNull saveCollection: Uri, @NonNull contentValues: ContentValues)

Creates options to write captured image to MediaStore.

<init>(@NonNull outputStream: OutputStream)

Creates options that write captured image to a OutputStream.

Public methods

ImageCapture.OutputFileOptions

Builds OutputFileOptions.

ImageCapture.OutputFileOptions.Builder
setMetadata(@NonNull metadata: ImageCapture.Metadata)

Sets the metadata to be stored with the saved image.

Public constructors

<init>

Builder(@NonNull file: File)

Creates options to write captured image to a File.

Parameters
file File: save location of the image.

<init>

Builder(
    @NonNull contentResolver: ContentResolver,
    @NonNull saveCollection: Uri,
    @NonNull contentValues: ContentValues)

Creates options to write captured image to MediaStore. Example:

<code>ContentValues contentValues = new ContentValues();
              contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, "NEW_IMAGE");
              contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "image/jpg");
             
              ImageCapture.OutputFileOptions options = new ImageCapture.OutputFileOptions.Builder(
                      getContentResolver(),
                      MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                      contentValues).build();
             
              </code>

Parameters
contentResolver ContentResolver: to access MediaStore
saveCollection Uri: The URL of the table to insert into.
contentValues ContentValues: to be included in the created image file.

<init>

Builder(@NonNull outputStream: OutputStream)

Creates options that write captured image to a OutputStream.

Parameters
outputStream OutputStream: save location of the image.

Public methods

build

@NonNull fun build(): ImageCapture.OutputFileOptions

Builds OutputFileOptions.

setMetadata

@NonNull fun setMetadata(@NonNull metadata: ImageCapture.Metadata): ImageCapture.OutputFileOptions.Builder

Sets the metadata to be stored with the saved image.

For JPEG this will be included in the EXIF.

Parameters
metadata ImageCapture.Metadata: Metadata to be stored with the saved image. For JPEG this will be included in the EXIF.