# ActivityResultContracts.PickVisualMedia

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.PickVisualMedia) Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/activity#1.6.0)

*** ** * ** ***


```
open class ActivityResultContracts.PickVisualMedia : ActivityResultContract<PickVisualMediaRequest, 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), [Uri](https://developer.android.com/reference/android/net/Uri.html)?\> ||
|   | ↳ | [androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia) |

*** ** * ** ***

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 a single image, video, or other type 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 ensure 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.

- `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.

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

The output is a `Uri` when the user has selected a media or `null` when the user hasn't selected any item. Keep in mind that `Uri` returned by the photo picker isn't writable.

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

## Summary

| ### Nested types |
|---|
| `abstract class https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.DefaultTab` Represents filter input type accepted by the photo picker. |
| `object https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.DefaultTab.AlbumsTab : https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.DefaultTab` `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.DefaultTab` object used to open the picker in Albums tab. |
| `object https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.DefaultTab.PhotosTab : https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.DefaultTab` `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.DefaultTab` object used to open the picker in Photos tab (also the default if no value is provided). |
| `object https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.ImageAndVideo : https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.VisualMediaType` `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.VisualMediaType` object used to filter images and video when using the photo picker. |
| `object https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.ImageOnly : https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.VisualMediaType` `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.VisualMediaType` object used to filter images only when using the photo picker. |
| `class https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.MediaCapabilities` Represents the media capabilities of an application. |
| `class https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.MediaCapabilities.Builder` A builder for constructing `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.MediaCapabilities` instances. |
| `class https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.SingleMimeType : https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.VisualMediaType` `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.VisualMediaType` class used to filter a single mime type only when using the photo picker. |
| `object https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.VideoOnly : https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.VisualMediaType` `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.VisualMediaType` object used to filter video only when using the photo picker. |
| `sealed interface https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia.VisualMediaType` Represents filter input type accepted by the photo picker. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#ACTION_SYSTEM_FALLBACK_PICK_IMAGES()` In cases where the system framework provided `https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_PICK_IMAGES` Photo Picker cannot be implemented, OEMs or system apps can provide a consistent Photo Picker experience to those devices by creating an Activity that handles this action. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#EXTRA_SYSTEM_FALLBACK_PICK_IMAGES_ACCENT_COLOR()` Extra that will be sent by `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia` and `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia` to an Activity that handles `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#ACTION_SYSTEM_FALLBACK_PICK_IMAGES()` that indicates the preferred accent color of the picker. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#EXTRA_SYSTEM_FALLBACK_PICK_IMAGES_IN_ORDER()` Extra that will be sent by `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia` to an Activity that handles `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#ACTION_SYSTEM_FALLBACK_PICK_IMAGES()` that indicates allowing the user to control the order in which images are returned to the calling app. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#EXTRA_SYSTEM_FALLBACK_PICK_IMAGES_LAUNCH_TAB()` Extra that will be sent by `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia` and `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia` to an Activity that handles `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#ACTION_SYSTEM_FALLBACK_PICK_IMAGES()` that indicates the preferred default tab of the picker. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#EXTRA_SYSTEM_FALLBACK_PICK_IMAGES_MAX()` Extra that will be sent by `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia` to an Activity that handles `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#ACTION_SYSTEM_FALLBACK_PICK_IMAGES()` that indicates that maximum number of photos the user should select. |

| ### Public companion functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[isPhotoPickerAvailable](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#isPhotoPickerAvailable())()` **This function is deprecated.** This method is deprecated in favor of isPhotoPickerAvailable(context) to support the picker provided by updatable system apps |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#isPhotoPickerAvailable(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` Check if the current device has support for the photo picker by checking the running Android version, the SDK extension version or the picker provided by a system app implementing `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#ACTION_SYSTEM_FALLBACK_PICK_IMAGES()`. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#PickVisualMedia()()` |

| ### 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.PickVisualMedia#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://developer.android.com/reference/android/net/Uri.html?>?` | `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#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://developer.android.com/reference/android/net/Uri.html?` | `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#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`. |

## Constants

### ACTION_SYSTEM_FALLBACK_PICK_IMAGES

```
const val ACTION_SYSTEM_FALLBACK_PICK_IMAGES: String
```

In cases where the system framework provided `https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_PICK_IMAGES` Photo Picker cannot be implemented, OEMs or system apps can provide a consistent Photo Picker experience to those devices by creating an Activity that handles this action. This app must also include `https://developer.android.com/reference/android/content/Intent.html#CATEGORY_DEFAULT` in the activity's intent filter.

Only system apps can implement this action - any non-system apps will be ignored when searching for the activities that handle this Intent.

Note: this should not be used directly, instead relying on the selection logic done by `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#createIntent(android.content.Context,androidx.activity.result.PickVisualMediaRequest)` to create the correct Intent for the current device.

### EXTRA_SYSTEM_FALLBACK_PICK_IMAGES_ACCENT_COLOR

```
const val EXTRA_SYSTEM_FALLBACK_PICK_IMAGES_ACCENT_COLOR: String
```

Extra that will be sent by `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia` and `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia` to an Activity that handles `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#ACTION_SYSTEM_FALLBACK_PICK_IMAGES()` that indicates the preferred accent color of the picker.

If this extra is not present, the default accent color of the picker will be used.

### EXTRA_SYSTEM_FALLBACK_PICK_IMAGES_IN_ORDER

```
const val EXTRA_SYSTEM_FALLBACK_PICK_IMAGES_IN_ORDER: String
```

Extra that will be sent by `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia` to an Activity that handles `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#ACTION_SYSTEM_FALLBACK_PICK_IMAGES()` that indicates allowing the user to control the order in which images are returned to the calling app.

### EXTRA_SYSTEM_FALLBACK_PICK_IMAGES_LAUNCH_TAB

```
const val EXTRA_SYSTEM_FALLBACK_PICK_IMAGES_LAUNCH_TAB: String
```

Extra that will be sent by `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia` and `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia` to an Activity that handles `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#ACTION_SYSTEM_FALLBACK_PICK_IMAGES()` that indicates the preferred default tab of the picker.

If this extra is not present, the default tab of the picker will be used.

### EXTRA_SYSTEM_FALLBACK_PICK_IMAGES_MAX

```
const val EXTRA_SYSTEM_FALLBACK_PICK_IMAGES_MAX: String
```

Extra that will be sent by `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia` to an Activity that handles `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#ACTION_SYSTEM_FALLBACK_PICK_IMAGES()` that indicates that maximum number of photos the user should select.

If this extra is not present, only a single photo should be selectable.

If this extra is present but equal to `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/-companion/-m-a-x_-v-a-l-u-e.html`, then no limit should be enforced.

## Public companion functions

### isPhotoPickerAvailable

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

```
fun [isPhotoPickerAvailable](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#isPhotoPickerAvailable())(): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
> This method is deprecated in favor of isPhotoPickerAvailable(context) to support the picker provided by updatable system apps, use this instead:
>
> ```kotlin
> isPhotoPickerAvailable(context)
> ```

Check if the current device has support for the photo picker by checking the running Android version or the SDK extension version.

Note that this does not check for any Intent handled by `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#ACTION_SYSTEM_FALLBACK_PICK_IMAGES()`.

### isPhotoPickerAvailable

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

```
fun isPhotoPickerAvailable(context: Context): Boolean
```

Check if the current device has support for the photo picker by checking the running Android version, the SDK extension version or the picker provided by a system app implementing `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia#ACTION_SYSTEM_FALLBACK_PICK_IMAGES()`.

## Public constructors

### PickVisualMedia

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

```
PickVisualMedia()
```

## 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<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://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?): 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`.