# Person.Builder

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

# Builder

*** ** * ** ***

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

```
class Builder
```

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

Builder for the immutable[Person](https://developer.android.com/reference/kotlin/android/app/Person)class.

## Summary

|                                                                                               Public constructors                                                                                                ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#Builder())`()` Creates a new, empty[Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#). |

|                                                                                                                                                                              Public methods                                                                                                                                                                               ||
|--------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Person](https://developer.android.com/reference/kotlin/android/app/Person)                  | [build](https://developer.android.com/reference/kotlin/android/app/Person.Builder#build())`()` Creates and returns the[Person](https://developer.android.com/reference/kotlin/android/app/Person)this builder represents.                                               |
| open[Person.Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#) | [setBot](https://developer.android.com/reference/kotlin/android/app/Person.Builder#setBot(kotlin.Boolean))`(`isBot:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Sets whether this person is a machine rather than a human.  |
| open[Person.Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#) | [setIcon](https://developer.android.com/reference/kotlin/android/app/Person.Builder#setIcon(android.graphics.drawable.Icon))`(`icon:` `[Icon](https://developer.android.com/reference/kotlin/android/graphics/drawable/Icon.html#)?`)` Add an icon for this person.     |
| open[Person.Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#) | [setImportant](https://developer.android.com/reference/kotlin/android/app/Person.Builder#setImportant(kotlin.Boolean))`(`isImportant:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Sets whether this is an important person. |
| open[Person.Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#) | [setKey](https://developer.android.com/reference/kotlin/android/app/Person.Builder#setKey(kotlin.String))`(`key:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?`)` Add a key to this person in order to uniquely identify it.      |
| open[Person.Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#) | [setName](https://developer.android.com/reference/kotlin/android/app/Person.Builder#setName(kotlin.CharSequence))`(`name:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?`)` Give this person a name.                  |
| open[Person.Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#) | [setUri](https://developer.android.com/reference/kotlin/android/app/Person.Builder#setUri(kotlin.String))`(`uri:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?`)` Set a URI associated with this person.                          |

## Public constructors

### Builder

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

```
Builder()
```

Creates a new, empty[Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#).

## Public methods

### build

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

```
open fun build(): Person
```

Creates and returns the[Person](https://developer.android.com/reference/kotlin/android/app/Person)this builder represents.

|                                                  Return                                                  ||
|-----------------------------------------------------------------------------|-----------------------------|
| [Person](https://developer.android.com/reference/kotlin/android/app/Person) | This value cannot be`null`. |

### setBot

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

```
open fun setBot(isBot: Boolean): Person.Builder
```

Sets whether this person is a machine rather than a human.

|                                                                   Parameters                                                                    ||
|---------|----------------------------------------------------------------------------------------------------------------------------------------|
| `isBot` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):`true`if this person is a machine,`false`otherwise. |

|                                                          Return                                                           ||
|----------------------------------------------------------------------------------------------|-----------------------------|
| [Person.Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#) | This value cannot be`null`. |

### setIcon

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

```
open fun setIcon(icon: Icon?): Person.Builder
```

Add an icon for this person.  
The system will prefer this icon over any images that are resolved from the URI.

|                                                                      Parameters                                                                       ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| `icon` | [Icon](https://developer.android.com/reference/kotlin/android/graphics/drawable/Icon.html#)?:the icon of the person. This value may be`null`. |

|                                                          Return                                                           ||
|----------------------------------------------------------------------------------------------|-----------------------------|
| [Person.Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#) | This value cannot be`null`. |

### setImportant

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

```
open fun setImportant(isImportant: Boolean): Person.Builder
```

Sets whether this is an important person. Use this method to denote users who frequently interact with the user of this device when[setUri(java.lang.String)](https://developer.android.com/reference/kotlin/android/app/Person.Builder#setUri(kotlin.String))isn't provided with[android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI](https://developer.android.com/reference/kotlin/android/provider/ContactsContract.Contacts.html#CONTENT_LOOKUP_URI:android.net.Uri), and instead with the`mailto:`or`tel:`schemas.

|                                                                        Parameters                                                                        ||
|---------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `isImportant` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):`true`if this is an important person,`false`otherwise. |

|                                                          Return                                                           ||
|----------------------------------------------------------------------------------------------|-----------------------------|
| [Person.Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#) | This value cannot be`null`. |

### setKey

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

```
open fun setKey(key: String?): Person.Builder
```

Add a key to this person in order to uniquely identify it. This is especially useful if the name doesn't uniquely identify this person or if the display name is a short handle of the actual name.

If no key is provided, the name serves as the key for the purpose of identification.

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

|                                                          Return                                                           ||
|----------------------------------------------------------------------------------------------|-----------------------------|
| [Person.Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#) | This value cannot be`null`. |

### setName

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

```
open fun setName(name: CharSequence?): Person.Builder
```

Give this person a name.

|                                                                        Parameters                                                                        ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| `name` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?:the name of this person. This value may be`null`. |

|                                                          Return                                                           ||
|----------------------------------------------------------------------------------------------|-----------------------------|
| [Person.Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#) | This value cannot be`null`. |

### setUri

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

```
open fun setUri(uri: String?): Person.Builder
```

Set a URI associated with this person.

The person should be specified by the`String`representation of a[android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI](https://developer.android.com/reference/kotlin/android/provider/ContactsContract.Contacts.html#CONTENT_LOOKUP_URI:android.net.Uri).

The system will also attempt to resolve`mailto:`and`tel:`schema URIs. The path part of these URIs must exist in the contacts database, in the appropriate column, or the reference will be discarded as invalid. Telephone schema URIs will be resolved by[android.provider.ContactsContract.PhoneLookup](https://developer.android.com/reference/kotlin/android/provider/ContactsContract.PhoneLookup.html#).

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

|                                                          Return                                                           ||
|----------------------------------------------------------------------------------------------|-----------------------------|
| [Person.Builder](https://developer.android.com/reference/kotlin/android/app/Person.Builder#) | This value cannot be`null`. |