Person.Builder


public static class Person.Builder
extends Object

java.lang.Object
   ↳ android.app.Person.Builder


Builder for the immutable Person class.

Summary

Public constructors

Builder()

Creates a new, empty Builder.

Public methods

Person build()

Creates and returns the Person this builder represents.

Person.Builder setBot(boolean isBot)

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

Person.Builder setIcon(Icon icon)

Add an icon for this person.

Person.Builder setImportant(boolean isImportant)

Sets whether this is an important person.

Person.Builder setKey(String key)

Add a key to this person in order to uniquely identify it.

Person.Builder setName(CharSequence name)

Give this person a name.

Person.Builder setUri(String uri)

Set a URI associated with this person.

Inherited methods

Public constructors

Builder

Added in API level 28
public Builder ()

Creates a new, empty Builder.

Public methods

build

Added in API level 28
public Person build ()

Creates and returns the Person this builder represents.

Returns
Person This value cannot be null.

setBot

Added in API level 28
public Person.Builder setBot (boolean isBot)

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

Parameters
isBot boolean: true if this person is a machine, false otherwise.

Returns
Person.Builder This value cannot be null.

setIcon

Added in API level 28
public Person.Builder setIcon (Icon icon)

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.

Returns
Person.Builder This value cannot be null.

setImportant

Added in API level 28
public Person.Builder setImportant (boolean isImportant)

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) isn't provided with ContactsContract.Contacts.CONTENT_LOOKUP_URI, and instead with the mailto: or tel: schemas.

Parameters
isImportant boolean: true if this is an important person, false otherwise.

Returns
Person.Builder This value cannot be null.

setKey

Added in API level 28
public Person.Builder setKey (String key)

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.

Returns
Person.Builder This value cannot be null.

setName

Added in API level 28
public Person.Builder setName (CharSequence name)

Give this person a name.

Parameters
name CharSequence: the name of this person. This value may be null.

Returns
Person.Builder This value cannot be null.

setUri

Added in API level 28
public Person.Builder setUri (String uri)

Set a URI associated with this person.

The person should be specified by the String representation of a ContactsContract.Contacts.CONTENT_LOOKUP_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 ContactsContract.PhoneLookup.

Parameters
uri String: a URI for the person. This value may be null.

Returns
Person.Builder This value cannot be null.