FMX.Address Book Sample
This demo is an FMX application that shows how to use the TAddressBook component to access the Address Book on an Android or iOS device.
You can find the Address Book sample project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples, and then navigate to:
Object Pascal\Multi-Device Samples\Device Sensors and Services\Address Book\Contacts
CPP\Multi-Device Samples\Device Sensors and Services\Address Book\Contacts
- Subversion Repository:
- You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
This sample project illustrates how to display and interact with a device Address Book, including the following techniques:
- Requesting a permission to access a mobile device Address Book (Android or iOS).
- Retrieving contacts and groups from the default source in the Address Book.
- Creation/deletion of contacts.
- Creation/deletion of the contact groups.
How to Use the Sample
- Navigate to the location given above, and open:
- Delphi: Contacts_Delphi.dproj
- C++: Contacts_CPP.cbproj
- Select Android or iOS Device as the Target Platform.
- Select the device.
- Press F9 or choose Run > Run.
When you run the sample demo, the application opens the Address Book tab that displays all contacts available in the device Address Book (default source):
This sub-section describes all tabs you can use to manage the device Address Book.
The Address Book Tab
On this tab, you can perform the following operations:
- Delete a currently selected contact:
- Refresh the contact list:
The Add Contact Tab
On this tab, you can add a new contact to Address Book.
To add a contact
- Enter the appropriate information in the Enter First Name, Enter Last Name, or Enter Work Email field.
- Optionally, select the contact person photo from a device photo library or take the photo from a device camera.
To do this, use the icons next to Add Photo.
- Optionally, from the Select Group list, select a group where to add the newly created contact.
- Tap the Add button.
The Add/Remove Group Tab
On this tab, you can add or remove the contact groups.
To add a new group
To remove an existing group
Requesting a Permission to Access Address Book
Filling the Contact and Group Lists
- If the permission is granted:
- If permission is not granted, the application displays a message box, which informs that the user is not allowed to access the Address Book.
Tracking Changes in Address Book