# 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)
public final class SelectionParams.Builder
```

<br />

*** ** * ** ***

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

## Summary

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

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

```
public Builder()
```

## Public methods

### build

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

```
public final @NonNull SelectionParams build()
```

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/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)

```
public final @NonNull SelectionParams.Builder clearMaxMediaItemResolution()
```

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/androidx/annotation/NonNull https://developer.android.com/reference/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)

```
public final @NonNull SelectionParams.Builder clearMaxMediaItemSize()
```

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/androidx/annotation/NonNull https://developer.android.com/reference/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)

```
public final @NonNull SelectionParams.Builder clearMaxSelectionBatchSize()
```

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/androidx/annotation/NonNull https://developer.android.com/reference/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)

```
public final @NonNull SelectionParams.Builder clearMaxVideoDuration()
```

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/androidx/annotation/NonNull https://developer.android.com/reference/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)

```
public final @NonNull SelectionParams.Builder clearMimeTypes()
```

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/androidx/annotation/NonNull https://developer.android.com/reference/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)

```
public final @NonNull SelectionParams.Builder clearMinMediaItemResolution()
```

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/androidx/annotation/NonNull https://developer.android.com/reference/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)

```
public final @NonNull SelectionParams.Builder clearMinVideoDuration()
```

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/androidx/annotation/NonNull https://developer.android.com/reference/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)

```
public final @NonNull SelectionParams.Builder setMaxMediaItemResolutionInPixels(long maxMediaItemResolutionInPixels)
```

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/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxMediaItemResolutionInPixels(kotlin.Long)`, there will be no restriction on the maximum resolution.

| Parameters |
|---|---|
| `long maxMediaItemResolutionInPixels` | The maximum media item resolution in total pixels. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/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/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)

```
public final @NonNull SelectionParams.Builder setMaxMediaItemSizeInBytes(long maxMediaItemSizeInBytes)
```

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/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxMediaItemSizeInBytes(kotlin.Long)`, there will be no restriction on the maximum media item size.

| Parameters |
|---|---|
| `long maxMediaItemSizeInBytes` | The maximum size in bytes. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/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/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)

```
public final @NonNull SelectionParams.Builder setMaxSelectionBatchSizeInBytes(long maxSelectionBatchSizeInBytes)
```

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/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxSelectionBatchSizeInBytes(kotlin.Long)`, there will be no restriction on the cumulative size of selected media items.

| Parameters |
|---|---|
| `long maxSelectionBatchSizeInBytes` | The maximum batch size in bytes. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/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/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)

```
public final @NonNull SelectionParams.Builder setMaxVideoDuration(@NonNull Duration maxVideoDuration)
```

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/androidx/photopicker/activity/params/SelectionParams.Builder#setMaxVideoDuration(java.time.Duration)`, there will be no restriction on the maximum video duration.

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/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/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)

```
public final @NonNull SelectionParams.Builder setMimeTypes(@NonNull List<@NonNull String> mimeTypes)
```

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/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/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/androidx/photopicker/activity/params/SelectionParams.Builder#setMimeTypes(kotlin.collections.List)` controls which displayed items are enabled for selection.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html> mimeTypes` | The list of allowed mime types. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/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/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)

```
public final @NonNull SelectionParams.Builder setMinMediaItemResolutionInPixels(long minMediaItemResolutionInPixels)
```

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/androidx/photopicker/activity/params/SelectionParams.Builder#setMinMediaItemResolutionInPixels(kotlin.Long)`, there will be no restriction on the minimum resolution.

| Parameters |
|---|---|
| `long minMediaItemResolutionInPixels` | The minimum allowed resolution in total pixels. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/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/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)

```
public final @NonNull SelectionParams.Builder setMinVideoDuration(@NonNull Duration minVideoDuration)
```

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/androidx/photopicker/activity/params/SelectionParams.Builder#setMinVideoDuration(java.time.Duration)`, there will be no restriction on the minimum video duration.

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/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/androidx/photopicker/activity/params/SelectionParams.Builder#setMinVideoDuration(java.time.Duration)` is not positive. |