# Class Contact

java.lang.Object
com.codename1.contacts.Contact

public class Contact extends java.lang.Object

Represents a Contact entry from the device Address Book.

The sample below demonstrates listing all the contacts within the device with their photos

    Form hi = new Form("Contacts", new BoxLayout(BoxLayout.Y_AXIS));
    hi.add(new InfiniteProgress());
    int size = Display.getInstance().convertToPixels(5, true);
    FontImage fi = FontImage.createFixed("" + FontImage.MATERIAL_PERSON, FontImage.getMaterialDesignFont(), 0xff, size, size);

    Display.getInstance().scheduleBackgroundTask(() -> {
        Contact[] contacts = Display.getInstance().getAllContacts(true, true, false, true, false, false);
        Display.getInstance().callSerially(() -> {
            hi.removeAll();
            for(Contact c : contacts) {
                MultiButton mb = new MultiButton(c.getDisplayName());
                mb.setIcon(fi);
                mb.setTextLine2(c.getPrimaryPhoneNumber());
                hi.add(mb);
                mb.putClientProperty("id", c.getId());
                Display.getInstance().scheduleBackgroundTask(() -> {
                    Contact cc = ContactsManager.getContactById(c.getId(), false, true, false, false, false);
                    Display.getInstance().callSerially(() -> {
                        Image photo = cc.getPhoto();
                        if(photo != null) {
                            mb.setIcon(photo.fill(size, size));
                            mb.revalidate();
                        }
                    });
                });
            }
            hi.getContentPane().animateLayout(150);
        });
    });

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Contact()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Hashtable`
  `getAddresses()`
  Gets the Contact Addresses, the Hashtable contains key/value pairs where the key is a String which represents the type of the Address, types can be: "home", "work", "other" the value is an Address Object.
  `long`
  `getBirthday()`
  Gets the Contact birthday
  `String`
  `getDisplayName()`
  Gets the Contact Display Name
  `Hashtable`
  `getEmails()`
  Gets the Contact Emails, the Hashtable contains key/value pairs where the key is a String which represents the type of the Email, types can be: "home", "mobile", "work", "other" the value is String of the email.
  `String`
  `getFamilyName()`
  Gets Contact family name
  `String`
  `getFirstName()`
  Gets Contact First Name
  `String`
  `getId()`
  Gets the Contact unique id
  `String[]`
  `getLinkedContactIds()`
  Returns the IDs of all contacts that are linked to this contact.
  `String`
  `getNote()`
  Gets Contact Note
  `Hashtable`
  `getPhoneNumbers()`
  Gets the Contact phone numbers, the Hashtable contains key/value pairs where the key is a String which represents the type of the phone number, types can be: "home", "mobile", "work", "fax", "other" the value is String of the phone number.
  `Image`
  `getPhoto()`
  Gets the Contact photo
  `String`
  `getPrimaryEmail()`
  Gets the primary email of this Contact, notice this can be null even though the Contact has emails declared
  `String`
  `getPrimaryPhoneNumber()`
  Gets the primary phone number of this Contact, notice this can be null even though the Contact has phone numbers declared
  `String[]`
  `getUrls()`
  Gets Contact urls
  `void`
  `setAddresses(Hashtable addresses)`
  Sets the Contact Addresses
  `void`
  `setBirthday(long birthday)`
  Sets the Contact birthday date
  `void`
  `setDisplayName(String displayName)`
  Sets the Contact display name
  `void`
  `setEmails(Hashtable emails)`
  Sets the Contact emails
  `void`
  `setFamilyName(String familyName)`
  Sets Contact family name
  `void`
  `setFirstName(String name)`
  Sets Contact first name
  `void`
  `setId(String id)`
  Sets the Contact unique id
  `void`
  `setNote(String note)`
  Sets Contact note
  `void`
  `setPhoneNumbers(Hashtable phoneNumbers)`
  Sets Contact phone numbers
  `void`
  `setPhoto(Image photo)`
  Sets Contact photo
  `void`
  `setPrimaryEmail(String primaryEmail)`
  Sets Contact primary email
  `void`
  `setPrimaryPhoneNumber(String primaryPhoneNumber)`
  Sets Contact primary phone number
  `void`
  `setUrls(String[] urls)`
  Sets Contact urls

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Contact

    public Contact()

- ## Method Details

  - ### getAddresses

    public Hashtable getAddresses()

    Gets the Contact Addresses, the Hashtable contains key/value pairs where the key is a String which represents the type of the Address, types can be: "home", "work", "other" the value is an Address Object.

    ###### Returns

    Hashtable of available addresses

  - ### setAddresses

    public void setAddresses(Hashtable addresses)

    Sets the Contact Addresses

    ###### Parameters

    - `addresses`: @param addresses the Hashtable contains key/value pairs where the key is a String that represents the type of the Address, types can be: "home", "work", "other" the value is an Address Object.

  - ### getBirthday

    public long getBirthday()

    Gets the Contact birthday

    ###### Returns

    birth time

  - ### setBirthday

    public void setBirthday(long birthday)

    Sets the Contact birthday date

    ###### Parameters

    - `birthday`

  - ### getDisplayName

    public String getDisplayName()

    Gets the Contact Display Name

    ###### Returns

    Display Name

  - ### setDisplayName

    public void setDisplayName(String displayName)

    Sets the Contact display name

    ###### Parameters

    - `displayName`

  - ### getEmails

    public Hashtable getEmails()

    Gets the Contact Emails, the Hashtable contains key/value pairs where the key is a String which represents the type of the Email, types can be: "home", "mobile", "work", "other" the value is String of the email.

    ###### Returns

    Hashtable of available emails

  - ### setEmails

    public void setEmails(Hashtable emails)

    Sets the Contact emails

    ###### Parameters

    - `emails`: @param emails the Hashtable contains key/value pairs where the key is a String which represents the type of the Email, types can be: "home", "mobile", "work", "other" the value is String of the email.

  - ### getId

    public String getId()

    Gets the Contact unique id

    ###### Returns

    Contact unique id

  - ### setId

    public void setId(String id)

    Sets the Contact unique id

    ###### Parameters

    - `id`

  - ### getFirstName

    public String getFirstName()

    Gets Contact First Name

    ###### Returns

    Contact Name

  - ### setFirstName

    public void setFirstName(String name)

    Sets Contact first name

    ###### Parameters

    - `name`

  - ### getFamilyName

    public String getFamilyName()
    Gets Contact family name

  - ### setFamilyName

    public void setFamilyName(String familyName)

    Sets Contact family name

    ###### Parameters

    - `familyName`

  - ### getNote

    public String getNote()

    Gets Contact Note

    ###### Returns

    Contact Note

  - ### setNote

    public void setNote(String note)

    Sets Contact note

    ###### Parameters

    - `note`

  - ### getPhoneNumbers

    public Hashtable getPhoneNumbers()

    Gets the Contact phone numbers, the Hashtable contains key/value pairs where the key is a String which represents the type of the phone number, types can be: "home", "mobile", "work", "fax", "other" the value is String of the phone number.

    ###### Returns

    Hashtable of available phone numbers

  - ### setPhoneNumbers

    public void setPhoneNumbers(Hashtable phoneNumbers)

    Sets Contact phone numbers

    ###### Parameters

    - `phoneNumbers`: @param phoneNumbers the Hashtable contains key/value pairs where the key is a String which represents the type of the phone number, types can be: "home", "mobile", "work", "fax", "other" the value is String of the phone number.

  - ### getPhoto

    public Image getPhoto()

    Gets the Contact photo

    ###### Returns

    the Contact Photo or null if not available

  - ### setPhoto

    public void setPhoto(Image photo)

    Sets Contact photo

    ###### Parameters

    - `photo`

  - ### getPrimaryEmail

    public String getPrimaryEmail()

    Gets the primary email of this Contact, notice this can be null even though the Contact has emails declared

    ###### Returns

    the Contact primary email or null if not declared

  - ### setPrimaryEmail

    public void setPrimaryEmail(String primaryEmail)

    Sets Contact primary email

    ###### Parameters

    - `primaryEmail`

  - ### getPrimaryPhoneNumber

    public String getPrimaryPhoneNumber()

    Gets the primary phone number of this Contact, notice this can be null even though the Contact has phone numbers declared

    ###### Returns

    the Contact primary phone number or null if not declared

  - ### setPrimaryPhoneNumber

    public void setPrimaryPhoneNumber(String primaryPhoneNumber)

    Sets Contact primary phone number

    ###### Parameters

    - `primaryPhoneNumber`

  - ### getUrls

    public String[] getUrls()
    Gets Contact urls

  - ### setUrls

    public void setUrls(String[] urls)

    Sets Contact urls

    ###### Parameters

    - `urls`

  - ### getLinkedContactIds

    public String[] getLinkedContactIds()

    Returns the IDs of all contacts that are linked to this contact.

    ###### Returns

    IDs of all contacts that are linked to this contact.