How do I get Mobile Numbers using Delphi FMX Address Book component

  

Delphi 10.3.
Cross platform application.
Android & IOS.
I am using the TAddressbook component and the following code adapted from the Delphi code examples.
I am able to get the names and photos but cannot workout the syntax for the phone numbers.
The code fills the Listview with firstname / surname & image but the Contact.Phones seems to be an array.

I found this in the documentation

Phones.AddPhone(TContactPhone.TLabelKind.Mobile, ‘+33-6-46-51-3531’);
So I need somthing like this
Phones.Extract(TContactPhone.TLabelKind.Mobile); // Does not work.

procedure TformMain.FillContactList(Source: TAddressBookSource);
var
I: Integer;
Contacts: TAddressBookContacts;
begin
Contacts := TAddressBookContacts.Create;
try
AddressBook1.AllContacts(Source, Contacts);
ListViewContacts.BeginUpdate;
try
ListViewContacts.Items.Clear;
for I := 0 to Contacts.Count – 1 do
AddListViewItem(Contacts.Items[I]);
//AddListViewItem(Contacts.Items[I].Phones[0].Number)
finally
ListViewContacts.EndUpdate;
end;
finally
Contacts.Free;
end;
end;
procedure TformMain.AddListViewItem(Contact: TAddressBookContact);
var

ListViewItem: TListViewItem;
eMails: TContactEmails;
phones: TContactPhones;
c : TAddressBookContact;

begin

phones := Contact.Phones;
if Contact.DisplayName.Length > 0 then
begin
ListViewItem := ListViewContacts.Items.Add;
try

// ListViewItem.Data[‘Text2’] := Contact.Phones.Extract(TContactPhone.SupportedLabelKinds(‘Mobile’));
// ListViewItem.Data[‘Text2’] := Phones.ExtractItem.LabelText. (TContactPhone.TLabelKind.Mobile, ‘+33-6-46-51-3531’);
//ListViewItem.Data[‘Text2’] := Phones.ex ExtractItem AddPhone(TContactPhone.TLabelKind.Mobile, ‘+33-6-46-51-3531’);
ListViewItem.Data[‘Text1’] := Contact.DisplayName;
ListViewItem.Data[‘Text2’] := ‘07446944654’; // from sample eMails.AddEmail(TContactEmail.TLabelKind.Work, edtWorkMail.Text);
// TLabelKind = (Custom, Home, Mobile, Work, iPhone, FaxWork, FaxHome, FaxOther, Pager, Other, Callback, Car, CompanyMain,ISDN, Main, Radio, Telex, TTYTDD, WorkMobile, WorkPager, Assistant);
// ListViewItem.Data[‘Text2’] := c.Phones.First.LabelKind.Mobile.t;// Phones.IndexOf(‘Mobile’);
// ListViewItem.Data[‘Text2’] := Contact.Phones.ExtractItem(‘Mobile’);
// ListViewItem.Data[‘Text2’] := Contact.Phones.Extract.LabelKind(‘Mobile’);
// ListViewItem.Data[‘Text2’] := Contact.Phones.ExtractAt.LabelKind.Mobile;//(‘Mobile’);
// phones := Contact.Phones.ExtractItem.LabelKind.Mobile; //.TLabelKind.Mobile;// .Phones.Extract(Mobile);
// ListViewItem.Data[‘Text2’] := phones.ExtractAt.LabelKind.Mobile;// Extract.LabelKind.Mobile;// ExtractItem.LabelKind.Mobile;// Contact.Phones.Extract(‘Mobile’).ToString;// Phones.Extract.TLabelKind.;
// ListViewItem.Data[‘Text2’] := phones.Extract.LabelKind.Mobile;// Contact.Phones Items[0].TLabelKind. .Number;// .Items[0];
ListViewItem.Data[‘Image3’] := Contact.PhotoThumbnail;

ListViewItem.Tag := Contact.ID;
finally
ListViewItem.Free;
end;

end;

end;

Comments are closed.