public class Contact
- Object
- Contact
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);
});
});
Constructors
public Contact() |
Methods
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. |
public void setAddresses(Hashtable addresses) | Sets the Contact Addresses |
public long getBirthday() | Gets the Contact birthday |
public void setBirthday(long birthday) | Sets the Contact birthday date |
public String getDisplayName() | Gets the Contact Display Name |
public void setDisplayName(String displayName) | Sets the Contact display name |
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. |
public void setEmails(Hashtable emails) | Sets the Contact emails |
public String getId() | Gets the Contact unique id |
public void setId(String id) | Sets the Contact unique id |
public String getFirstName() | Gets Contact First Name |
public void setFirstName(String name) | Sets Contact first name |
public String getFamilyName() | Gets Contact family name |
public void setFamilyName(String familyName) | Sets Contact family name |
public String getNote() | Gets Contact Note |
public void setNote(String note) | Sets Contact note |
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. |
public void setPhoneNumbers(Hashtable phoneNumbers) | Sets Contact phone numbers |
public Image getPhoto() | Gets the Contact photo |
public void setPhoto(Image photo) | Sets Contact photo |
public String getPrimaryEmail() | Gets the primary email of this Contact, notice this can be null even though the Contact has emails declared |
public void setPrimaryEmail(String primaryEmail) | Sets Contact primary email |
public String getPrimaryPhoneNumber() | Gets the primary phone number of this Contact, notice this can be null even though the Contact has phone numbers declared |
public void setPrimaryPhoneNumber(String primaryPhoneNumber) | Sets Contact primary phone number |
public String[] getUrls() | Gets Contact urls |
public void setUrls(String[] urls) | Sets Contact urls |
public String[] getLinkedContactIds() | Returns the IDs of all contacts that are linked to this contact. |
Inherited methods
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
addressesHashtable- 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
getDisplayName
public String getDisplayName()Gets the Contact Display Name
Returns
Display Name
setDisplayName
public void setDisplayName(String displayName)Sets the Contact display name
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
emailsHashtable- 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
getFirstName
public String getFirstName()Gets Contact First Name
Returns
Contact Name
setFirstName
public void setFirstName(String name)Sets Contact first name
getFamilyName
public String getFamilyName()Gets Contact family name
setFamilyName
public void setFamilyName(String familyName)Sets Contact family name
getNote
public String getNote()Gets Contact Note
Returns
Contact Note
setNote
public void setNote(String note)Sets Contact 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
phoneNumbersHashtable- 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
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
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
getUrls
public String[] getUrls()Gets Contact urls
setUrls
public void setUrls(String[] urls)Sets Contact 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.