# ActivityResultContracts.GetContent

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

*** ** * ** ***


```
public class ActivityResultContracts.GetContent extends ActivityResultContract<@NonNull String, Uri>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.activity.result.contract.ActivityResultContract](https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract)\<@[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) [String](https://developer.android.com/reference/java/lang/String.html), [Uri](https://developer.android.com/reference/android/net/Uri.html)\> ||
|   | ↳ | [androidx.activity.result.contract.ActivityResultContracts.GetContent](https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts.GetContent) |

*** ** * ** ***

An `https://developer.android.com/reference/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. By default, this adds `https://developer.android.com/reference/android/content/Intent.html#CATEGORY_OPENABLE` to only return content that can be represented as a stream.

The input is the mime type to filter by, e.g. `image/\*`.

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

## Summary

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

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Intent.html` | `@https://developer.android.com/reference/androidx/annotation/CallSuper https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts.GetContent#createIntent(android.content.Context,kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html input)` 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/androidx/activity/result/contract/ActivityResultContract.SynchronousResult<https://developer.android.com/reference/android/net/Uri.html>` | `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts.GetContent#getSynchronousResult(android.content.Context,kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html input)` 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/androidx/activity/result/contract/ActivityResultContracts.GetContent#parseResult(kotlin.Int,android.content.Intent)(int resultCode, https://developer.android.com/reference/android/content/Intent.html intent)` 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/androidx/activity/result/contract/ActivityResultContract`. |

## Public constructors

### GetContent

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

```
public GetContent()
```

## Public methods

### createIntent

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

```
@CallSuper
public @NonNull Intent createIntent(@NonNull Context context, @NonNull String input)
```

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)

```
public final ActivityResultContract.SynchronousResult<Uri> getSynchronousResult(@NonNull Context context, @NonNull String input)
```

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/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/androidx/activity/result/contract/ActivityResultContract.SynchronousResult` or `null` if the call should proceed to start an activity. |

### parseResult

```
public final Uri parseResult(int resultCode, Intent intent)
```

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/androidx/activity/result/contract/ActivityResultContract`.