# ActivityResultContract

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/ActivityResultContract.kt+class:androidx.activity.result.contract.ActivityResultContract) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/activity#1.2.0)

*** ** * ** ***


```
abstract class ActivityResultContract<I : Any?, O : Any?>
```

<br />

Known direct subclasses [ActivityResultContracts.CaptureVideo](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.CaptureVideo), [ActivityResultContracts.CreateDocument](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.CreateDocument), [ActivityResultContracts.GetContent](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.GetContent), [ActivityResultContracts.GetMultipleContents](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.GetMultipleContents), [ActivityResultContracts.OpenDocumentTree](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.OpenDocumentTree), [ActivityResultContracts.OpenDocument](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.OpenDocument), [ActivityResultContracts.OpenMultipleDocuments](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.OpenMultipleDocuments), [ActivityResultContracts.PickContact](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickContact), [ActivityResultContracts.PickMultipleVisualMedia](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickMultipleVisualMedia), [ActivityResultContracts.PickVisualMedia](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickVisualMedia), [ActivityResultContracts.RequestMultiplePermissions](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.RequestMultiplePermissions), [ActivityResultContracts.RequestPermission](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.RequestPermission), [ActivityResultContracts.StartActivityForResult](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.StartActivityForResult), [ActivityResultContracts.StartIntentSenderForResult](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.StartIntentSenderForResult), [ActivityResultContracts.TakePicturePreview](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.TakePicturePreview), [ActivityResultContracts.TakePicture](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.TakePicture), [ActivityResultContracts.TakeVideo](https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.TakeVideo), [AuthTabIntent.AuthenticateUserResultContract](https://developer.android.com/reference/kotlin/androidx/browser/auth/AuthTabIntent.AuthenticateUserResultContract), [ExerciseRouteRequestContract](https://developer.android.com/reference/kotlin/androidx/health/connect/client/contracts/ExerciseRouteRequestContract), [HealthPermissionsRequestContract](https://developer.android.com/reference/kotlin/androidx/health/connect/client/contracts/HealthPermissionsRequestContract), [PickMultipleVisualMedia](https://developer.android.com/reference/kotlin/androidx/photopicker/activity/PickMultipleVisualMedia), [PickVisualMedia](https://developer.android.com/reference/kotlin/androidx/photopicker/activity/PickVisualMedia), [WatchFaceEditorContract](https://developer.android.com/reference/kotlin/androidx/wear/watchface/editor/WatchFaceEditorContract)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.CaptureVideo` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to `https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_VIDEO_CAPTURE` saving it into the provided content-`https://developer.android.com/reference/android/net/Uri.html`. |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.CreateDocument` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to prompt the user to select a path for creating a new document of the given `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.CreateDocument#mimeType()`, returning the `content:` `https://developer.android.com/reference/android/net/Uri.html` of the item that was created. |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.GetContent` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to prompt the user to pick a piece of content, receiving a `content://` `https://developer.android.com/reference/android/net/Uri.html` for that content that allows you to use `https://developer.android.com/reference/android/content/ContentResolver.html#openInputStream(android.net.Uri)` to access the raw data. |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.GetMultipleContents` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to prompt the user to pick one or more a pieces of content, receiving a `content://` `https://developer.android.com/reference/android/net/Uri.html` for each piece of content that allows you to use `https://developer.android.com/reference/android/content/ContentResolver.html#openInputStream(android.net.Uri)` to access the raw data. |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.OpenDocumentTree` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to prompt the user to select a directory, returning the user selection as a `https://developer.android.com/reference/android/net/Uri.html`. |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.OpenDocument` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to prompt the user to open a document, receiving its contents as a `file:/http:/content:` `https://developer.android.com/reference/android/net/Uri.html`. |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.OpenMultipleDocuments` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to prompt the user to open (possibly multiple) documents, receiving their contents as `file:/http:/content:` `https://developer.android.com/reference/android/net/Uri.html`s. |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.PickContact` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to request the user to pick a contact from the contacts app. |
| `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. |
| `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. |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.RequestMultiplePermissions` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to `https://developer.android.com/reference/android/app/Activity.html#requestPermissions(java.lang.String[], int)` |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.RequestPermission` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to `https://developer.android.com/reference/android/app/Activity.html#requestPermissions(java.lang.String[], int)` |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.StartActivityForResult` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` that doesn't do any type conversion, taking raw `https://developer.android.com/reference/android/content/Intent.html` as an input and `https://developer.android.com/reference/kotlin/androidx/activity/result/ActivityResult` as an output. |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.StartIntentSenderForResult` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` that calls `https://developer.android.com/reference/android/app/Activity.html#startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int)`. |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.TakePicturePreview` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to `https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE` preview, returning it as a `https://developer.android.com/reference/android/graphics/Bitmap.html`. |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.TakePicture` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to `https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE` saving it into the provided content-`https://developer.android.com/reference/android/net/Uri.html`. |
| `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContracts.TakeVideo` | **This class is deprecated.** The thumbnail bitmap is rarely returned and is not a good signal to determine whether the video was actually successfully captured. |
| `https://developer.android.com/reference/kotlin/androidx/browser/auth/AuthTabIntent.AuthenticateUserResultContract` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` for launching an Auth Tab and receiving the result. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/contracts/ExerciseRouteRequestContract` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to request a route associated with an `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/ExerciseSessionRecord`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/contracts/HealthPermissionsRequestContract` | An `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` to request Health permissions. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/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. |
| `https://developer.android.com/reference/kotlin/androidx/photopicker/activity/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. |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/editor/WatchFaceEditorContract` | **This class is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |

*** ** * ** ***

A contract specifying that an activity can be called with an input of type `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract` and produce an output of type `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract`.

Makes calling an activity for result type-safe.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/result/ActivityResultCaller` |   |

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract.SynchronousResult<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` The wrapper for a result provided in `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract#getSynchronousResult(android.content.Context,kotlin.Any)`. |

| ### Public constructors |
|---|
| `<I : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, O : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract#ActivityResultContract()()` |

| ### Public functions |
|---|---|
| `abstract https://developer.android.com/reference/android/content/Intent.html` | `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract#createIntent(android.content.Context,kotlin.Any)(context: https://developer.android.com/reference/android/content/Context.html, input: I)` Create an intent that can be used for `https://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)`. |
| `open https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract.SynchronousResult<O>?` | `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract#getSynchronousResult(android.content.Context,kotlin.Any)(context: https://developer.android.com/reference/android/content/Context.html, input: I)` An optional method you can implement that can be used to potentially provide a result in lieu of starting an activity. |
| `abstract O` | `https://developer.android.com/reference/kotlin/androidx/activity/result/contract/ActivityResultContract#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

### ActivityResultContract

```
<I : Any?, O : Any?> ActivityResultContract()
```

## Public functions

### createIntent

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

```
abstract fun createIntent(context: Context, input: I): 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.2.0](https://developer.android.com/jetpack/androidx/releases/activity#1.2.0)

```
open fun getSynchronousResult(context: Context, input: I): ActivityResultContract.SynchronousResult<O>?
```

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<O>?` | 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

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

```
abstract fun parseResult(resultCode: Int, intent: Intent?): O
```

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