Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/content/ContextParams.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/content/ContextParams.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/content/ContextParams.Builder#inhmethods)

# ContextParams.Builder

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/content/ContextParams.Builder "View this page in Kotlin") \|Java


`
public
static
final

class
ContextParams.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.content.ContextParams.Builder |

<br />

*** ** * ** ***

Builder for creating a `https://developer.android.com/reference/android/content/ContextParams`.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/content/ContextParams.Builder#Builder()() ` Create a new builder. |
| ` https://developer.android.com/reference/android/content/ContextParams.Builder#Builder(android.content.ContextParams)(https://developer.android.com/reference/android/content/ContextParams params) ` Create a new builder that inherits all sub-parameters by default. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/content/ContextParams` | ` https://developer.android.com/reference/android/content/ContextParams.Builder#build()() ` Creates a new instance. |
| ` https://developer.android.com/reference/android/content/ContextParams.Builder` | ` https://developer.android.com/reference/android/content/ContextParams.Builder#setAttributionTag(java.lang.String)(https://developer.android.com/reference/java/lang/String attributionTag) ` Sets an attribution tag against which to track permission accesses. |
| ` https://developer.android.com/reference/android/content/ContextParams.Builder` | ` https://developer.android.com/reference/android/content/ContextParams.Builder#setNextAttributionSource(android.content.AttributionSource)(https://developer.android.com/reference/android/content/AttributionSource next) ` Sets the attribution source for the app on whose behalf you are doing the work. |
| ` https://developer.android.com/reference/android/content/ContextParams.Builder` | ` https://developer.android.com/reference/android/content/ContextParams.Builder#setShouldRegisterAttributionSource(boolean)(boolean shouldRegister) ` Sets whether the attribution source associated with the context created from these params should be registered. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### Builder

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

```
public Builder ()
```

Create a new builder.


This is valuable when you are interested in having explicit control
over every sub-parameter, and don't want to inherit any values from
an existing Context.


Developers should strongly consider using
`https://developer.android.com/reference/android/content/ContextParams.Builder#Builder(android.content.ContextParams)` instead of this constructor, since
that will will automatically inherit any new sub-parameters added in
future platform releases.

<br />

### Builder

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

```
public Builder (ContextParams params)
```

Create a new builder that inherits all sub-parameters by default.


This is valuable when you are only interested in overriding specific
sub-parameters, and want to preserve all other parameters. Setting a
specific sub-parameter on the returned builder will override any
inherited value.

<br />

| Parameters ||
|---|---|
| `params` | `ContextParams`: This value cannot be `null`. <br /> |

## Public methods

### build

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

```
public ContextParams build ()
```

Creates a new instance.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContextParams` | The new instance. This value cannot be `null`. <br /> |

### setAttributionTag

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

```
public ContextParams.Builder setAttributionTag (String attributionTag)
```

Sets an attribution tag against which to track permission accesses.

<br />

| Parameters ||
|---|---|
| `attributionTag` | `String`: The attribution tag. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContextParams.Builder` | This builder. This value cannot be `null`. <br /> |

### setNextAttributionSource

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

```
public ContextParams.Builder setNextAttributionSource (AttributionSource next)
```

Sets the attribution source for the app on whose behalf you are doing the work.

<br />

| Parameters ||
|---|---|
| `next` | `AttributionSource`: The permission identity of the receiving app. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContextParams.Builder` | This builder. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/AttributionSource`

### setShouldRegisterAttributionSource

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

```
public ContextParams.Builder setShouldRegisterAttributionSource (boolean shouldRegister)
```

Sets whether the attribution source associated with the context created from these params
should be registered.

<br />

| Parameters ||
|---|---|
| `shouldRegister` | `boolean`: Whether the attribution source associated with the Context being created should be registered. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ContextParams.Builder` | This value cannot be `null`. <br /> |