# SelectionParams.Builder

Artifact: [androidx.photopicker:photopicker-activity](https://developer.android.com/jetpack/androidx/releases/photopicker) [View Source](https://cs.android.com/search?q=file:androidx/photopicker/activity/params/SelectionParams.kt+class:androidx.photopicker.activity.params.SelectionParams.Builder) Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

*** ** * ** ***


```
@RequiresApi(value = 26)
class SelectionParams.Builder
```

<br />

*** ** * ** ***

A builder for constructing `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#Builder()()` |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#build()()` Builds a new immutable `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams` object. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#clearMaxMediaItemResolution()()` Clears the maximum allowed resolution limit for media items. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#clearMaxMediaItemSize()()` Clears the maximum allowed size limit for individual media items. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#clearMaxSelectionBatchSize()()` Clears the maximum allowed cumulative batch size limit. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#clearMaxVideoDuration()()` Clears the maximum allowed duration limit for video media items. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#clearMimeTypes()()` Clears the allowed mime types selection constraint. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#clearMinMediaItemResolution()()` Clears the minimum allowed resolution limit for media items. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#clearMinVideoDuration()()` Clears the minimum allowed duration limit for video media items. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxMediaItemResolutionInPixels(kotlin.Long)(maxMediaItemResolutionInPixels: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the maximum allowed resolution constraint for a media item to be selectable. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxMediaItemSizeInBytes(kotlin.Long)(maxMediaItemSizeInBytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the maximum allowed size, in bytes, for any individual media item to be selectable. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxSelectionBatchSizeInBytes(kotlin.Long)(maxSelectionBatchSizeInBytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the maximum allowed cumulative size, in bytes, for the entire batch of selected media items. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxVideoDuration(java.time.Duration)(maxVideoDuration: https://developer.android.com/reference/java/time/Duration.html)` Sets the maximum allowed duration for a video media item to be selectable. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMimeTypes(kotlin.collections.List)(mimeTypes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>)` Sets the list of mime types that are allowed for selection. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMinMediaItemResolutionInPixels(kotlin.Long)(minMediaItemResolutionInPixels: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the minimum allowed resolution constraint for a media item to be selectable. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMinVideoDuration(java.time.Duration)(minVideoDuration: https://developer.android.com/reference/java/time/Duration.html)` Sets the minimum allowed duration for a video media item to be selectable. |

## Public constructors

### Builder

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
Builder()
```

## Public functions

### build

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun build(): SelectionParams
```

Builds a new immutable `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams` object.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams` | The newly constructed SelectionParams. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if minVideoDuration is greater than maxVideoDuration, or minMediaItemResolutionInPixels is greater than maxMediaItemResolutionInPixels. |

### clearMaxMediaItemResolution

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun clearMaxMediaItemResolution(): SelectionParams.Builder
```

Clears the maximum allowed resolution limit for media items.

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

### clearMaxMediaItemSize

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun clearMaxMediaItemSize(): SelectionParams.Builder
```

Clears the maximum allowed size limit for individual media items.

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

### clearMaxSelectionBatchSize

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun clearMaxSelectionBatchSize(): SelectionParams.Builder
```

Clears the maximum allowed cumulative batch size limit.

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

### clearMaxVideoDuration

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun clearMaxVideoDuration(): SelectionParams.Builder
```

Clears the maximum allowed duration limit for video media items.

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

### clearMimeTypes

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun clearMimeTypes(): SelectionParams.Builder
```

Clears the allowed mime types selection constraint.

On calling this, the PhotoPicker will not enforce allowed mime type constraints for selection.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

### clearMinMediaItemResolution

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun clearMinMediaItemResolution(): SelectionParams.Builder
```

Clears the minimum allowed resolution limit for media items.

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

### clearMinVideoDuration

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun clearMinVideoDuration(): SelectionParams.Builder
```

Clears the minimum allowed duration limit for video media items.

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

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

### setMaxMediaItemResolutionInPixels

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun setMaxMediaItemResolutionInPixels(maxMediaItemResolutionInPixels: Long): SelectionParams.Builder
```

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

Media items with total resolution (width \* height) exceeding this limit will be disabled and cannot be selected.

If the maximum resolution is not set by the caller app using `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxMediaItemResolutionInPixels(kotlin.Long)`, there will be no restriction on the maximum resolution.

| Parameters |
|---|---|
| `maxMediaItemResolutionInPixels: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The maximum media item resolution in total pixels. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxMediaItemResolutionInPixels(kotlin.Long)` is not positive. |

### setMaxMediaItemSizeInBytes

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun setMaxMediaItemSizeInBytes(maxMediaItemSizeInBytes: Long): SelectionParams.Builder
```

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

Media items exceeding this size will be disabled and cannot be selected.

If the maximum media item size is not set by the caller app using `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxMediaItemSizeInBytes(kotlin.Long)`, there will be no restriction on the maximum media item size.

| Parameters |
|---|---|
| `maxMediaItemSizeInBytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The maximum size in bytes. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxMediaItemSizeInBytes(kotlin.Long)` is not positive. |

### setMaxSelectionBatchSizeInBytes

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun setMaxSelectionBatchSizeInBytes(maxSelectionBatchSizeInBytes: Long): SelectionParams.Builder
```

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

This limits the aggregate size of all items selected in a single PhotoPicker session. If selecting an item causes the total cumulative size to exceed this limit, the user will be alerted that the maximum selection size has been reached and cannot add more items until existing selections are removed.

If the maximum selection batch size is not set by the caller app using `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxSelectionBatchSizeInBytes(kotlin.Long)`, there will be no restriction on the cumulative size of selected media items.

| Parameters |
|---|---|
| `maxSelectionBatchSizeInBytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The maximum batch size in bytes. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxSelectionBatchSizeInBytes(kotlin.Long)` is not positive. |

### setMaxVideoDuration

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun setMaxVideoDuration(maxVideoDuration: Duration): SelectionParams.Builder
```

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

Video items exceeding this duration will be disabled and cannot be selected.

If the maximum video duration is not set by the caller app using `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxVideoDuration(java.time.Duration)`, there will be no restriction on the maximum video duration.

| Parameters |
|---|---|
| `maxVideoDuration: https://developer.android.com/reference/java/time/Duration.html` | The maximum video duration. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxVideoDuration(java.time.Duration)` is not positive. |

### setMimeTypes

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun setMimeTypes(mimeTypes: List<String>): SelectionParams.Builder
```

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

Media items whose mime type is not in this list will be visible in the picker grid but disabled for selection.

If the allowed mime types are not set by the caller app using `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMimeTypes(kotlin.collections.List)`, all items matching the requested media type filter will be selectable.

This constraint is distinct from the media type filter specified via `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/PickVisualMediaRequest.Builder#setMediaType(androidx.photopicker.activity.PickVisualMedia.VisualMediaType)`. The media type in the request determines which items are queried and displayed in the PhotoPicker grid in the first place, whereas `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMimeTypes(kotlin.collections.List)` controls which displayed items are enabled for selection.

| Parameters |
|---|---|
| `mimeTypes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>` | The list of allowed mime types. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMimeTypes(kotlin.collections.List)` is empty or contains non-image/video mime types. |

### setMinMediaItemResolutionInPixels

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun setMinMediaItemResolutionInPixels(minMediaItemResolutionInPixels: Long): SelectionParams.Builder
```

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

Media items with total resolution (width \* height) below this limit will be disabled and cannot be selected.

If the minimum resolution is not set by the caller app using `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMinMediaItemResolutionInPixels(kotlin.Long)`, there will be no restriction on the minimum resolution.

| Parameters |
|---|---|
| `minMediaItemResolutionInPixels: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The minimum allowed resolution in total pixels. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMinMediaItemResolutionInPixels(kotlin.Long)` is negative. |

### setMinVideoDuration

Added in [1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/photopicker#1.0.0-alpha03)

```
fun setMinVideoDuration(minVideoDuration: Duration): SelectionParams.Builder
```

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

Video items shorter than this duration will be disabled and cannot be selected.

If the minimum video duration is not set by the caller app using `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMinVideoDuration(java.time.Duration)`, there will be no restriction on the minimum video duration.

| Parameters |
|---|---|
| `minVideoDuration: https://developer.android.com/reference/java/time/Duration.html` | The minimum video duration. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder` | This builder. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/params/SelectionParams.Builder#setMinVideoDuration(java.time.Duration)` is not positive. |