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

# Builder

*** ** * ** ***

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

```
class Builder
```

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

A builder for `https://developer.android.com/reference/kotlin/android/content/AttributionSource`

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#Builder(android.content.AttributionSource)(current: https://developer.android.com/reference/kotlin/android/content/AttributionSource)` Creates a builder that is ready to build a new `https://developer.android.com/reference/kotlin/android/content/AttributionSource` where all fields (primitive, immutable data, pointers) are copied from the given `https://developer.android.com/reference/kotlin/android/content/AttributionSource`. |
| `https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#Builder(kotlin.Int)(uid: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Creates a new Builder. |

| Public methods ||
|---|---|
| [AttributionSource](https://developer.android.com/reference/kotlin/android/content/AttributionSource) | `https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#build()()` Builds the instance. |
| [AttributionSource.Builder](https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#) | `https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#setAttributionTag(kotlin.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` The attribution tag of the app accessing the permission protected data. |
| [AttributionSource.Builder](https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#) | `https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#setDeviceId(kotlin.Int)(deviceId: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Set the device ID for this attribution source, permission check would happen against this device ID. |
| [AttributionSource.Builder](https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#) | `https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#setNext(android.content.AttributionSource)(value: https://developer.android.com/reference/kotlin/android/content/AttributionSource?)` The next app to receive the permission protected data. |
| [AttributionSource.Builder](https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#) | `https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#setPackageName(kotlin.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?)` The package that is accessing the permission protected data. |
| [AttributionSource.Builder](https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#) | `https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#setPid(kotlin.Int)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` The PID of the process that is accessing the permission protected data. |

## Public constructors

### Builder

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

```
Builder(current: AttributionSource)
```

Creates a builder that is ready to build a new `https://developer.android.com/reference/kotlin/android/content/AttributionSource` where all fields (primitive, immutable data, pointers) are copied from the given `https://developer.android.com/reference/kotlin/android/content/AttributionSource`. Builder methods can still be used to mutate fields further.

| Parameters ||
|---|---|
| `current` | [AttributionSource](https://developer.android.com/reference/kotlin/android/content/AttributionSource): The source to copy fields from. This value cannot be `null`. |

### Builder

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

```
Builder(uid: Int)
```

Creates a new Builder.

| Parameters ||
|---|---|
| `uid` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The UID that is accessing the permission protected data. |

## Public methods

### build

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

```
fun build(): AttributionSource
```

Builds the instance. This builder should not be touched after calling this!

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/content/AttributionSource` | This value cannot be `null`. |

### setAttributionTag

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

```
fun setAttributionTag(value: String?): AttributionSource.Builder
```

The attribution tag of the app accessing the permission protected data.

| Parameters ||
|---|---|
| `value` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#` | This value cannot be `null`. |

### setDeviceId

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

```
fun setDeviceId(deviceId: Int): AttributionSource.Builder
```

Set the device ID for this attribution source, permission check would happen against this device ID.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#` | the builder. This value cannot be `null`. |

### setNext

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

```
fun setNext(value: AttributionSource?): AttributionSource.Builder
```

The next app to receive the permission protected data.

| Parameters ||
|---|---|
| `value` | [AttributionSource](https://developer.android.com/reference/kotlin/android/content/AttributionSource)?: This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#` | This value cannot be `null`. |

### setPackageName

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

```
fun setPackageName(value: String?): AttributionSource.Builder
```

The package that is accessing the permission protected data.

| Parameters ||
|---|---|
| `value` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#` | This value cannot be `null`. |

### setPid

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

```
fun setPid(value: Int): AttributionSource.Builder
```

The PID of the process that is accessing the permission protected data. If not called, pid will default to `https://developer.android.com/reference/kotlin/android/os/Process.html#INVALID_PID:kotlin.Int` (-1). This indicates that the PID data is missing. Supplying a PID is not required, but recommended when accessible.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/content/AttributionSource.Builder#` | This value cannot be `null`. |