public class ContactsManager extends Object
ContactsManager
provides access to the contacts on the device for listing, adding and deleting contacts.
The sample below demonstrates listing all the contacts within the device with their photos
Constructor and Description |
---|
ContactsManager() |
Modifier and Type | Method and Description |
---|---|
static String |
createContact(String firstName,
String familyName,
String workPhone,
String homePhone,
String mobilePhone,
String email)
Create a contact to the device contacts book
|
static boolean |
deleteContact(String id)
removed a contact from the device contacts book
|
static String[] |
getAllContacts()
This method returns all contacts IDs
|
Contact[] |
getAllContacts(boolean withNumbers,
boolean includesFullName,
boolean includesPicture,
boolean includesNumbers,
boolean includesEmail,
boolean includeAddress)
Deprecated.
this method was incorrectly introduced use getContacts instead
|
static String[] |
getAllContactsWithNumbers()
This method returns all contacts that has a phone number
|
static Contact |
getContactById(String id)
This method returns a Contact by the contact id
|
static Contact |
getContactById(String id,
boolean includesFullName,
boolean includesPicture,
boolean includesNumbers,
boolean includesEmail,
boolean includeAddress)
This method returns a Contact by the contact id and fills it's data
according to the given flags
|
static Contact[] |
getContacts(boolean withNumbers,
boolean includesFullName,
boolean includesPicture,
boolean includesNumbers,
boolean includesEmail,
boolean includeAddress)
Notice: this method might be very slow and should be invoked on a separate thread!
It might have platform specific optimizations over getAllContacts followed by looping
over individual contacts but that isn't guaranteed.
|
static boolean |
isAllContactsFast()
Indicates if the getAllContacts is platform optimized, notice that the method
might still take seconds or more to run so you should still use a separate thread!
|
boolean |
isGetAllContactsFast()
Deprecated.
this method was incorrectly introduced and isn't static use isAllContactsFast instead
|
static void |
refresh()
Clears the contacts cache to that they will be loaded from the system the next time
getContacts(boolean, boolean, boolean, boolean, boolean, boolean)
is called. |
public static String[] getAllContacts()
public static String[] getAllContactsWithNumbers()
public static Contact getContactById(String id)
id
- of the Contactpublic static Contact getContactById(String id, boolean includesFullName, boolean includesPicture, boolean includesNumbers, boolean includesEmail, boolean includeAddress)
id
- of the ContactincludesFullName
- if true try to fetch the full name of the Contact(not just display name)includesPicture
- if true try to fetch the Contact Picture if existsincludesNumbers
- if true try to fetch all Contact numbersincludesEmail
- if ture try to fetch all Contact EmailsincludeAddress
- if ture try to fetch all Contact Addressespublic static String createContact(String firstName, String familyName, String workPhone, String homePhone, String mobilePhone, String email)
firstName
- the Contact firstNamefamilyName
- the Contact familyNameworkPhone
- the Contact work phone or nullhomePhone
- the Contact home phone or nullmobilePhone
- the Contact mobile phone or nullemail
- the Contact email or nullpublic static boolean deleteContact(String id)
id
- the contact id to removepublic Contact[] getAllContacts(boolean withNumbers, boolean includesFullName, boolean includesPicture, boolean includesNumbers, boolean includesEmail, boolean includeAddress)
withNumbers
- if true returns only contacts that has a numberincludesFullName
- if true try to fetch the full name of the Contact(not just display name)includesPicture
- if true try to fetch the Contact Picture if existsincludesNumbers
- if true try to fetch all Contact numbersincludesEmail
- if true try to fetch all Contact EmailsincludeAddress
- if true try to fetch all Contact Addressespublic boolean isGetAllContactsFast()
public static Contact[] getContacts(boolean withNumbers, boolean includesFullName, boolean includesPicture, boolean includesNumbers, boolean includesEmail, boolean includeAddress)
withNumbers
- if true returns only contacts that has a numberincludesFullName
- if true try to fetch the full name of the Contact(not just display name)includesPicture
- if true try to fetch the Contact Picture if existsincludesNumbers
- if true try to fetch all Contact numbersincludesEmail
- if true try to fetch all Contact EmailsincludeAddress
- if true try to fetch all Contact Addressespublic static boolean isAllContactsFast()
public static void refresh()
getContacts(boolean, boolean, boolean, boolean, boolean, boolean)
is called.
This is only necessary on platforms that use a transactional address book, if you want to reload contact changes that have occurred outside the app. At time of writing, the only platform that does this is iOS. This method will have no effect on other platforms.