# AttributionSource.Builder

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/AttributionSource.Builder#pubctors)\|[Methods](https://developer.android.com/reference/android/content/AttributionSource.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/content/AttributionSource.Builder#inhmethods)  

# AttributionSource.Builder

*** ** * ** ***

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

`
public
static
final

class
AttributionSource.Builder
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

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

<br />

*** ** * ** ***

A builder for[AttributionSource](https://developer.android.com/reference/android/content/AttributionSource)

## Summary

|                                                                                                                                                                                                                                                                                ### Public constructors                                                                                                                                                                                                                                                                                 ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Builder](https://developer.android.com/reference/android/content/AttributionSource.Builder#Builder(android.content.AttributionSource))`(`[AttributionSource](https://developer.android.com/reference/android/content/AttributionSource)` current) ` Creates a builder that is ready to build a new[AttributionSource](https://developer.android.com/reference/android/content/AttributionSource)where all fields (primitive, immutable data, pointers) are copied from the given[AttributionSource](https://developer.android.com/reference/android/content/AttributionSource). |
| ` `[Builder](https://developer.android.com/reference/android/content/AttributionSource.Builder#Builder(int))`(int uid) ` Creates a new Builder.                                                                                                                                                                                                                                                                                                                                                                                                                                     |

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

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Builder (AttributionSource current)
```

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

<br />

|                                             Parameters                                             ||
|-----------|-----------------------------------------------------------------------------------------|
| `current` | `AttributionSource`: The source to copy fields from. This value cannot be`null`. <br /> |

### Builder

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

```
public Builder (int uid)
```

Creates a new Builder.

<br />

|                                  Parameters                                   ||
|-------|------------------------------------------------------------------------|
| `uid` | `int`: The UID that is accessing the permission protected data. <br /> |

## Public methods

### build

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

```
public AttributionSource build ()
```

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

<br />

|                                                              Returns                                                               ||
|------------------------------------------------------------------------------------------------|------------------------------------|
| [AttributionSource](https://developer.android.com/reference/android/content/AttributionSource) | This value cannot be`null`. <br /> |

### setAttributionTag

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

```
public AttributionSource.Builder setAttributionTag (String value)
```

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

<br />

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

|                                                                      Returns                                                                       ||
|----------------------------------------------------------------------------------------------------------------|------------------------------------|
| [AttributionSource.Builder](https://developer.android.com/reference/android/content/AttributionSource.Builder) | This value cannot be`null`. <br /> |

### setDeviceId

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

```
public AttributionSource.Builder setDeviceId (int deviceId)
```

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

<br />

|        Parameters        ||
|------------|--------------|
| `deviceId` | `int` <br /> |

|                                                                            Returns                                                                             ||
|----------------------------------------------------------------------------------------------------------------|------------------------------------------------|
| [AttributionSource.Builder](https://developer.android.com/reference/android/content/AttributionSource.Builder) | the builder This value cannot be`null`. <br /> |

### setNext

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

```
public AttributionSource.Builder setNext (AttributionSource value)
```

The next app to receive the permission protected data.

<br />

|                          Parameters                           ||
|---------|------------------------------------------------------|
| `value` | `AttributionSource`: This value may be`null`. <br /> |

|                                                                      Returns                                                                       ||
|----------------------------------------------------------------------------------------------------------------|------------------------------------|
| [AttributionSource.Builder](https://developer.android.com/reference/android/content/AttributionSource.Builder) | This value cannot be`null`. <br /> |

### setPackageName

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

```
public AttributionSource.Builder setPackageName (String value)
```

The package that is accessing the permission protected data.

<br />

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

|                                                                      Returns                                                                       ||
|----------------------------------------------------------------------------------------------------------------|------------------------------------|
| [AttributionSource.Builder](https://developer.android.com/reference/android/content/AttributionSource.Builder) | This value cannot be`null`. <br /> |

### setPid

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

```
public AttributionSource.Builder setPid (int value)
```

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

<br />

|      Parameters       ||
|---------|--------------|
| `value` | `int` <br /> |

|                                                                      Returns                                                                       ||
|----------------------------------------------------------------------------------------------------------------|------------------------------------|
| [AttributionSource.Builder](https://developer.android.com/reference/android/content/AttributionSource.Builder) | This value cannot be`null`. <br /> |