# ActivityResultContracts.PickMultipleVisualMedia

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/result/contract/ActivityResultContracts.kt+class:androidx.activity.result.contract.ActivityResultContracts.PickMultipleVisualMedia) Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/activity#1.6.0)

*** ** * ** ***


```
open class ActivityResultContracts.PickMultipleVisualMedia : ActivityResultContract<PickVisualMediaRequest, List<Uri>>
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.activity.result.contract.ActivityResultContract](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract)\<[PickVisualMediaRequest](https://developer.android.com/reference/kotlin/androidx/activity/result/PickVisualMediaRequest), [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)\<[Uri](https://developer.android.com/reference/android/net/Uri.html)\>\> ||
|   | ↳ | [androidx.activity.result.contract.ActivityResultContracts.PickMultipleVisualMedia](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia) |

*** ** * ** ***

An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to use the [Photo Picker](https://developer.android.com/training/data-storage/shared/photopicker) to select multiple images, videos, or other types of visual media.

This contract always prefers the system framework provided Photo Picker available via `https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_PICK_IMAGES` when it is available, but will also provide a fallback on devices that it is not available to provide a consistent API surface across all Android API 19 or higher devices.

The priority order for handling the Photo Picker is:

1. The system framework provided `https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_PICK_IMAGES`.

- An OEM can provide a system app that implements `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#ACTION_SYSTEM_FALLBACK_PICK_IMAGES()` to provide a consistent Photo Picker to older devices. These system apps may handle the `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#EXTRA_SYSTEM_FALLBACK_PICK_IMAGES_MAX()` extra to respect the `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia#maxItems()` passed to this contract.

- `https://developer.android.com/reference/android/content/Intent.html#ACTION_OPEN_DOCUMENT` is used as a final fallback on all Android API 19 or higher devices. This Intent does not allow limiting the max items the user selects.

The constructor accepts one parameter `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia#maxItems()` to limit the number of selectable items when using the photo picker to return. When launching the activity, the minimum of `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia#maxItems()` and input `https://developer.android.com/reference/kotlin/androidx/activity/result/PickVisualMediaRequest#maxItems()` is set as the limit.

The input is a `https://developer.android.com/reference/kotlin/androidx/activity/result/PickVisualMediaRequest`.

The output is a list `Uri` of the selected media. It can be empty if the user hasn't selected any items. Keep in mind that `Uri` returned by the photo picker aren't writable.

This can be extended to override `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia#createIntent(android.content.Context,androidx.activity.result.PickVisualMediaRequest)` if you wish to pass additional extras to the Intent created by `super.createIntent()`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia#PickMultipleVisualMedia(kotlin.Int)(maxItems: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |

| ### Public functions |
|---|---|
| `open https://developer.android.com/reference/android/content/Intent.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia#createIntent(android.content.Context,androidx.activity.result.PickVisualMediaRequest)(context: https://developer.android.com/reference/android/content/Context.html, input: https://developer.android.com/reference/kotlin/androidx/activity/result/PickVisualMediaRequest)` Create an intent that can be used for `https://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)`. |
| `final https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract.SynchronousResult<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/net/Uri.html>>?` | `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia#getSynchronousResult(android.content.Context,androidx.activity.result.PickVisualMediaRequest)(context: https://developer.android.com/reference/android/content/Context.html, input: https://developer.android.com/reference/kotlin/androidx/activity/result/PickVisualMediaRequest)` An optional method you can implement that can be used to potentially provide a result in lieu of starting an activity. |
| `final https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/net/Uri.html>` | `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia#parseResult(kotlin.Int,android.content.Intent)(resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, intent: https://developer.android.com/reference/android/content/Intent.html?)` Convert result obtained from `https://developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)` to `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract`. |

## Public constructors

### PickMultipleVisualMedia

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/activity#1.6.0)

```
PickMultipleVisualMedia(maxItems: Int = getMaxItems())
```

## Public functions

### createIntent

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/activity#1.6.0)

```
@CallSuper
open fun createIntent(context: Context, input: PickVisualMediaRequest): Intent
```

Create an intent that can be used for `https://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)`.

### getSynchronousResult

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/activity#1.6.0)

```
final fun getSynchronousResult(context: Context, input: PickVisualMediaRequest): ActivityResultContract.SynchronousResult<List<Uri>>?
```

An optional method you can implement that can be used to potentially provide a result in lieu of starting an activity.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract.SynchronousResult<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/net/Uri.html>>?` | the result wrapped in a `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract.SynchronousResult` or `null` if the call should proceed to start an activity. |

### parseResult

```
final fun parseResult(resultCode: Int, intent: Intent?): List<Uri>
```

Convert result obtained from `https://developer.android.com/reference/android/app/Activity.html#onActivityResult(int, int, android.content.Intent)` to `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract`.