# ContentCaptureContext.Builder

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/view/contentcapture/ContentCaptureContext.Builder "View this page in Java")  

```
class Builder
```

|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                         ||
| ↳ | [android.view.contentcapture.ContentCaptureContext.Builder](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureContext.Builder#) |

Builder for[ContentCaptureContext](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureContext)objects.

## Summary

|                                                                                                                                Public constructors                                                                                                                                ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureContext.Builder#Builder(android.content.LocusId))`(`id:` `[LocusId](https://developer.android.com/reference/kotlin/android/content/LocusId.html#)`)` Creates a new builder. |

|                                                                                                                                                                                                                 Public methods                                                                                                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ContentCaptureContext](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureContext)                  | [build](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureContext.Builder#build())`()` Builds the[ContentCaptureContext](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureContext).                                  |
| [ContentCaptureContext.Builder](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureContext.Builder#) | [setExtras](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureContext.Builder#setExtras(android.os.Bundle))`(`extras:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)`)` Sets extra options associated with this context. |

## Public constructors

### Builder

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(id: LocusId)
```

Creates a new builder.

The context must have an id, which is usually one of the following:

- A URL representing a web page (or`IFRAME`) that's being rendered by the activity (See[View.setContentCaptureSession(ContentCaptureSession)](https://developer.android.com/reference/kotlin/android/view/View.html#setContentCaptureSession(android.view.contentcapture.ContentCaptureSession))for an example).
- A unique identifier of the application state (for example, a conversation between 2 users in a chat app).

See[ContentCaptureManager](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureManager)for more info about the content capture context.

|                                                                         Parameters                                                                         ||
|------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id` | [LocusId](https://developer.android.com/reference/kotlin/android/content/LocusId.html#):id associated with this context. This value cannot be`null`. |

## Public methods

### build

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun build(): ContentCaptureContext
```

Builds the[ContentCaptureContext](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureContext).

|                                                                                         Return                                                                                         ||
|---------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------|
| [ContentCaptureContext](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureContext) | the built`ContentCaptureContext`This value cannot be`null`. |

|                                                                                     Exceptions                                                                                      ||
|-----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| `java.lang.IllegalStateException` | if[build()](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureContext.Builder#build())was already called. |

### setExtras

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setExtras(extras: Bundle): ContentCaptureContext.Builder
```

Sets extra options associated with this context.

It can be used to provide vendor-specific data that can be modified and examined.

|                                                              Parameters                                                               ||
|----------|-----------------------------------------------------------------------------------------------------------------------------|
| `extras` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#):extra options. This value cannot be`null`. |

|                                                                                        Return                                                                                         ||
|--------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [ContentCaptureContext.Builder](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureContext.Builder#) | this builder. This value cannot be`null`. |

|                                                                                     Exceptions                                                                                      ||
|-----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| `java.lang.IllegalStateException` | if[build()](https://developer.android.com/reference/kotlin/android/view/contentcapture/ContentCaptureContext.Builder#build())was already called. |