Class 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);
});
});
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets 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.longGets the Contact birthdayGets the Contact Display NameGets 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.Gets Contact family nameGets Contact First NamegetId()Gets the Contact unique idString[]Returns the IDs of all contacts that are linked to this contact.getNote()Gets Contact NoteGets 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.getPhoto()Gets the Contact photoGets the primary email of this Contact, notice this can be null even though the Contact has emails declaredGets the primary phone number of this Contact, notice this can be null even though the Contact has phone numbers declaredString[]getUrls()Gets Contact urlsvoidsetAddresses(Hashtable addresses) Sets the Contact AddressesvoidsetBirthday(long birthday) Sets the Contact birthday datevoidsetDisplayName(String displayName) Sets the Contact display namevoidSets the Contact emailsvoidsetFamilyName(String familyName) Sets Contact family namevoidsetFirstName(String name) Sets Contact first namevoidSets the Contact unique idvoidSets Contact notevoidsetPhoneNumbers(Hashtable phoneNumbers) Sets Contact phone numbersvoidSets Contact photovoidsetPrimaryEmail(String primaryEmail) Sets Contact primary emailvoidsetPrimaryPhoneNumber(String primaryPhoneNumber) Sets Contact primary phone numbervoidSets Contact urls
-
Constructor Details
-
Contact
public Contact()
-
-
Method Details
-
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
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
Gets the Contact Display Name
Returns
Display Name
-
setDisplayName
Sets the Contact display name
Parameters
displayName
-
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
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
Gets the Contact unique id
Returns
Contact unique id
-
setId
Sets the Contact unique id
Parameters
id
-
getFirstName
Gets Contact First Name
Returns
Contact Name
-
setFirstName
Sets Contact first name
Parameters
name
-
getFamilyName
Gets Contact family name -
setFamilyName
Sets Contact family name
Parameters
familyName
-
getNote
Gets Contact Note
Returns
Contact Note
-
setNote
Sets Contact note
Parameters
note
-
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
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
Gets the Contact photo
Returns
the Contact Photo or null if not available
-
setPhoto
Sets Contact photo
Parameters
photo
-
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
Sets Contact primary email
Parameters
primaryEmail
-
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
Sets Contact primary phone number
Parameters
primaryPhoneNumber
-
getUrls
Gets Contact urls -
setUrls
Sets Contact urls
Parameters
urls
-
getLinkedContactIds
Returns the IDs of all contacts that are linked to this contact.
Returns
IDs of all contacts that are linked to this contact.
-