Stay organized with collections
Save and categorize content based on your preferences.
Builder
class Builder
Builder for the immutable Person
class.
Summary
Public constructors |
Creates a new, empty Builder .
|
Public constructors
Builder
Builder()
Creates a new, empty Builder
.
Public methods
build
open fun build(): Person
Creates and returns the Person
this builder represents.
Return |
Person |
This value cannot be null . |
setBot
open fun setBot(isBot: Boolean): Person.Builder
Sets whether this person is a machine rather than a human.
Parameters |
isBot |
Boolean: true if this person is a machine, false otherwise. |
setIcon
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?: the icon of the person. This value may be null . |
setKey
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?: the key that uniquely identifies this person. This value may be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Person.Builder\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nBuilder\n=======\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/app/Person.Builder \"View this page in Java\") \n\n```\nclass Builder\n```\n\n|---|---------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.app.Person.Builder](#) |\n\nBuilder for the immutable [Person](/reference/kotlin/android/app/Person) class.\n\nSummary\n-------\n\n| Public constructors ||\n|--------------------------------------------------------------|---|\n| [Builder](#Builder())`()` Creates a new, empty [Builder](#). |\n\n| Public methods ||\n|-----------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Person](/reference/kotlin/android/app/Person) | [build](#build())`()` Creates and returns the [Person](/reference/kotlin/android/app/Person) this builder represents. |\n| open [Person.Builder](#) | [setBot](#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. |\n| open [Person.Builder](#) | [setIcon](#setIcon(android.graphics.drawable.Icon))`(`icon:` `[Icon](../graphics/drawable/Icon.html#)?`)` Add an icon for this person. |\n| open [Person.Builder](#) | [setImportant](#setImportant(kotlin.Boolean))`(`isImportant:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Sets whether this is an important person. |\n| open [Person.Builder](#) | [setKey](#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. |\n| open [Person.Builder](#) | [setName](#setName(kotlin.CharSequence))`(`name:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?`)` Give this person a name. |\n| open [Person.Builder](#) | [setUri](#setUri(kotlin.String))`(`uri:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?`)` Set a URI associated with this person. |\n\nPublic constructors\n-------------------\n\n### Builder\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nBuilder()\n```\n\nCreates a new, empty [Builder](#).\n\nPublic methods\n--------------\n\n### build\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun build(): Person\n```\n\nCreates and returns the [Person](/reference/kotlin/android/app/Person) this builder represents.\n\n| Return ||\n|------------------------------------------------|------------------------------|\n| [Person](/reference/kotlin/android/app/Person) | This value cannot be `null`. |\n\n### setBot\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun setBot(isBot: Boolean): Person.Builder\n```\n\nSets whether this person is a machine rather than a human.\n\n| Parameters ||\n|---------|--------------------------------------------------------------------------------------------------------------------------------------------|\n| `isBot` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` if this person is a machine, `false` otherwise. |\n\n| Return ||\n|---------------------|------------------------------|\n| [Person.Builder](#) | This value cannot be `null`. |\n\n### setIcon\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun setIcon(icon: Icon?): Person.Builder\n```\n\nAdd an icon for this person. \nThe system will prefer this icon over any images that are resolved from the URI.\n\n| Parameters ||\n|--------|---------------------------------------------------------------------------------------------|\n| `icon` | [Icon](../graphics/drawable/Icon.html#)?: the icon of the person. This value may be `null`. |\n\n| Return ||\n|---------------------|------------------------------|\n| [Person.Builder](#) | This value cannot be `null`. |\n\n### setImportant\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun setImportant(isImportant: Boolean): Person.Builder\n```\n\nSets 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)](#setUri(kotlin.String)) isn't provided with [android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI](../provider/ContactsContract.Contacts.html#CONTENT_LOOKUP_URI:android.net.Uri), and instead with the `mailto:` or `tel:` schemas.\n\n| Parameters ||\n|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------|\n| `isImportant` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` if this is an important person, `false` otherwise. |\n\n| Return ||\n|---------------------|------------------------------|\n| [Person.Builder](#) | This value cannot be `null`. |\n\n### setKey\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun setKey(key: String?): Person.Builder\n```\n\nAdd 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.\n\nIf no key is provided, the name serves as the key for the purpose of identification.\n\n| Parameters ||\n|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `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`. |\n\n| Return ||\n|---------------------|------------------------------|\n| [Person.Builder](#) | This value cannot be `null`. |\n\n### setName\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun setName(name: CharSequence?): Person.Builder\n```\n\nGive this person a name.\n\n| Parameters ||\n|--------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `name` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?: the name of this person. This value may be `null`. |\n\n| Return ||\n|---------------------|------------------------------|\n| [Person.Builder](#) | This value cannot be `null`. |\n\n### setUri\n\nAdded in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun setUri(uri: String?): Person.Builder\n```\n\nSet a URI associated with this person.\n\nThe person should be specified by the `String` representation of a [android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI](../provider/ContactsContract.Contacts.html#CONTENT_LOOKUP_URI:android.net.Uri).\n\nThe 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](../provider/ContactsContract.PhoneLookup.html#).\n\n| Parameters ||\n|-------|------------------------------------------------------------------------------------------------------------------------------------|\n| `uri` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: a URI for the person. This value may be `null`. |\n\n| Return ||\n|---------------------|------------------------------|\n| [Person.Builder](#) | This value cannot be `null`. |"]]