Builder


class Builder
kotlin.Any
   ↳ android.widget.photopicker.PhotoPickerSelectionParams.Builder

A builder class used to construct and validate an immutable PhotoPickerSelectionParams object.

Summary

Public constructors

Public methods
PhotoPickerSelectionParams

Builds a new immutable PhotoPickerSelectionParams object.

PhotoPickerSelectionParams.Builder

Clears the maximum media item resolution constraint.

PhotoPickerSelectionParams.Builder

Clears the maximum media item size constraint.

PhotoPickerSelectionParams.Builder

Clears the maximum cumulative selection size constraint.

PhotoPickerSelectionParams.Builder

Clears the maximum video duration constraint.

PhotoPickerSelectionParams.Builder

Clears the MIME type constraint.

PhotoPickerSelectionParams.Builder

Clears the minimum media item resolution constraint.

PhotoPickerSelectionParams.Builder

Clears the minimum video duration constraint.

PhotoPickerSelectionParams.Builder
setMaxMediaItemResolutionInPixels(maxMediaItemResolutionInPixels: Long)

Sets the maximum allowed resolution constraint for a media item to be selectable.

PhotoPickerSelectionParams.Builder
setMaxMediaItemSizeInBytes(maxMediaItemSizeInBytes: Long)

Sets the maximum allowed size, in bytes, for any individual media item to be selectable.

PhotoPickerSelectionParams.Builder
setMaxSelectionBatchSizeInBytes(maxSelectionBatchSizeInBytes: Long)

Sets the maximum allowed cumulative size, in bytes, for the entire batch of selected media items.

PhotoPickerSelectionParams.Builder
setMaxVideoDuration(maxVideoDuration: Duration)

Sets the maximum allowed duration for a video media item to be selectable.

PhotoPickerSelectionParams.Builder

Sets the list of MIME types that are allowed for selection.

PhotoPickerSelectionParams.Builder
setMinMediaItemResolutionInPixels(minMediaItemResolutionInPixels: Long)

Sets the minimum allowed resolution constraint for a media item to be selectable.

PhotoPickerSelectionParams.Builder
setMinVideoDuration(minVideoDuration: Duration)

Sets the minimum allowed duration for a video media item to be selectable.

Public constructors

Builder

Builder()

Public methods

build

fun build(): PhotoPickerSelectionParams

Builds a new immutable PhotoPickerSelectionParams object.

Return
PhotoPickerSelectionParams A new PhotoPickerSelectionParams object with the configured properties.
This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if any of the minimum values are greater than their corresponding maximum values.

clearMaxMediaItemResolution

fun clearMaxMediaItemResolution(): PhotoPickerSelectionParams.Builder

Clears the maximum media item resolution constraint.

On calling this, the PhotoPicker will not enforce an upper limit on the total resolution of individual media items.

Return
PhotoPickerSelectionParams.Builder This value cannot be null.

clearMaxMediaItemSize

fun clearMaxMediaItemSize(): PhotoPickerSelectionParams.Builder

Clears the maximum media item size constraint.

On calling this, the PhotoPicker will not enforce an upper limit on the size of individual media items.

Return
PhotoPickerSelectionParams.Builder This value cannot be null.

clearMaxSelectionBatchSize

fun clearMaxSelectionBatchSize(): PhotoPickerSelectionParams.Builder

Clears the maximum cumulative selection size constraint.

On calling this, the PhotoPicker will not enforce a limit on the total aggregate size of the selected media items in a single session.

Return
PhotoPickerSelectionParams.Builder This value cannot be null.

clearMaxVideoDuration

fun clearMaxVideoDuration(): PhotoPickerSelectionParams.Builder

Clears the maximum video duration constraint.

On calling this, the PhotoPicker will not enforce an upper limit on the duration of video media items.

Return
PhotoPickerSelectionParams.Builder This value cannot be null.

clearMimeTypes

fun clearMimeTypes(): PhotoPickerSelectionParams.Builder

Clears the MIME type constraint.

On calling this, the builder will revert to its default state of allowing all supported media MIME types (images and videos) for selection.

Return
PhotoPickerSelectionParams.Builder This value cannot be null.

clearMinMediaItemResolution

fun clearMinMediaItemResolution(): PhotoPickerSelectionParams.Builder

Clears the minimum media item resolution constraint.

On calling this, the PhotoPicker will not enforce a lower limit on the total resolution of individual media items.

Return
PhotoPickerSelectionParams.Builder This value cannot be null.

clearMinVideoDuration

fun clearMinVideoDuration(): PhotoPickerSelectionParams.Builder

Clears the minimum video duration constraint.

On calling this, the PhotoPicker will not enforce a lower limit on the duration of video media items.

Return
PhotoPickerSelectionParams.Builder This value cannot be null.

setMaxMediaItemResolutionInPixels

fun setMaxMediaItemResolutionInPixels(maxMediaItemResolutionInPixels: Long): PhotoPickerSelectionParams.Builder

Sets the maximum allowed resolution constraint for a media item to be selectable.

Items exceeding the provided resolution will be disabled for selection.

The maximum resolution should not be less than the minimum resolution, or an exception will be thrown during the build() process.

If it is not set, no maximum resolution constraint will be enforced on the media items that the user can select.

Parameters
maxMediaItemResolutionInPixels Long: The maximum media item resolution in pixels
Return
PhotoPickerSelectionParams.Builder This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if maxMediaItemResolutionInPixels is negative or zero

setMaxMediaItemSizeInBytes

fun setMaxMediaItemSizeInBytes(maxMediaItemSizeInBytes: Long): PhotoPickerSelectionParams.Builder

Sets the maximum allowed size, in bytes, for any individual media item to be selectable.

The calling application can set this to limit the size of media returned by the PhotoPicker. Items exceeding this limit will be disabled for selection.

If it is not set, no maximum size constraint will be enforced on the media items that the user can select.

Parameters
maxMediaItemSizeInBytes Long: The maximum size in bytes.
Return
PhotoPickerSelectionParams.Builder This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if maxMediaItemSizeInBytes is negative or zero

setMaxSelectionBatchSizeInBytes

fun setMaxSelectionBatchSizeInBytes(maxSelectionBatchSizeInBytes: Long): PhotoPickerSelectionParams.Builder

Sets the maximum allowed cumulative size, in bytes, for the entire batch of selected media items.

This limits the total aggregate size of the media selected by the user. If a new selection causes the total size to exceed this limit, the user will be alerted that they have reached the maximum selection size limit and must deselect items before proceeding.

If it is not set, no collective batch size constraint will be enforced on media items that the user can select.

Parameters
maxSelectionBatchSizeInBytes Long: The maximum batch size in bytes.
Return
PhotoPickerSelectionParams.Builder This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if maxSelectionBatchSizeInBytes is negative or zero

setMaxVideoDuration

fun setMaxVideoDuration(maxVideoDuration: Duration): PhotoPickerSelectionParams.Builder

Sets the maximum allowed duration for a video media item to be selectable.

Videos exceeding this duration will be disabled for selection.

The maximum duration should not be less than minimum duration, or an exception will be thrown during the build() process.

If it is not set, no maximum video duration constraint will be enforced on the videos that the user can select.

Parameters
maxVideoDuration Duration: The maximum video duration.
This value cannot be null.
Return
PhotoPickerSelectionParams.Builder This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if maxVideoDuration is null, negative or zero

setMimeTypes

fun setMimeTypes(mimeTypes: MutableList<String!>): PhotoPickerSelectionParams.Builder

Sets the list of MIME types that are allowed for selection.

Media items that violate this constraint will be disabled for selection.

This parameter is different from the MIME types which can be specified in android.content.Intent.setType(String) extra or android.content.Intent#EXTRA_MIME_TYPES, when those are used to launch the photo picker, they will filter out any media items which has a MIME type not added to them. While the MIME Types defined by this API will still exist in photo picker media grid, but disabled from selection.

Filter media items using the MIME Types defined in android.content.Intent.setType(String) extra or android.content.Intent#EXTRA_MIME_TYPES will happen first, before disabling the media items based on the MIME Types passed to this API.

Callers must indicate the acceptable document MIME types. For example, to select photos, use image/*.

If it is not set, no MIME type constraint will be enforced on the media items the user can select.

Parameters
mimeTypes MutableList<String!>: The list of allowed MIME types.
This value cannot be null.
Return
PhotoPickerSelectionParams.Builder This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if mimeTypes is null, empty, or contains non-media types (types not starting with "image/" or "video/").

setMinMediaItemResolutionInPixels

fun setMinMediaItemResolutionInPixels(minMediaItemResolutionInPixels: Long): PhotoPickerSelectionParams.Builder

Sets the minimum allowed resolution constraint for a media item to be selectable.

Media items with a resolution lower than the provided threshold will be disabled for selection.

The minimum resolution should not be greater than the maximum resolution, or an exception will be thrown during the build() process.

If it is not set, no minimum resolution constraint will be enforced on the media items that the user can select.

Parameters
minMediaItemResolutionInPixels Long: The minimum allowed resolution in total pixels.
Return
PhotoPickerSelectionParams.Builder This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if minMediaItemResolutionInPixels is negative.

setMinVideoDuration

fun setMinVideoDuration(minVideoDuration: Duration): PhotoPickerSelectionParams.Builder

Sets the minimum allowed duration for a video media item to be selectable.

Videos shorter than this duration will be disabled for selection.

The maximum duration should not be less than minimum duration, or an exception will be thrown during the build() process.

If it is not set, no minimum video duration constraint will be enforced on the videos that the user can select.

Parameters
minVideoDuration Duration: The minimum video duration.
This value cannot be null.
Return
PhotoPickerSelectionParams.Builder This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if minVideoDuration is negative