![]() |
Delphi-Version: 10.3 Rio
How do I extract the array of contact telephone numbers using Delphi FMX TAddressboo
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
Code:
Phones.AddPhone(TContactPhone.TLabelKind.Mobile, '+33-6-46-51-3531');
So I need something like this Phones.Extract(TContactPhone.TLabelKind.Mobile); // Does not work.
Code:
```
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]); finally ListViewContacts.EndUpdate; end; finally Contacts.Free; end; end; procedure TformMain.AddListViewItem(Contact: TAddressBookContact); var ListViewItem: TListViewItem; begin ListViewItem := ListViewContacts.Items.Add; try ListViewItem.Data['Text1'] := Contact.DisplayName; ListViewItem.Data['Text2'] := Contact.Phones; ListViewItem.Data['Image3'] := Contact.PhotoThumbnail; //ListViewItem.Text := Contact.DisplayName; //ListViewItem.Text2:= Contact.Phones; ListViewItem.Tag := Contact.ID; finally ListViewItem.Free; end; end; eMails: TContactEmails; phones: TContactPhones; c : TAddressBookContact; //phoneType : TLabelKind ; begin // Contact.DisplayName <> '' then // eMails.AddEmail(TContactEmail.TLabelKind.Work, edtWorkMail.Text); // if (Contacts.Items[I].Phones.Count >= 1) and (not Contacts.Items[I].Phones[0].Number.IsEmpty) then // LItem.Data[TMultiDetailAppearanceNames.Detail1] := Contacts.Items[I].Phones[0].Number; phones := Contact.Phones; if Contact.DisplayName.Length > 0 then begin ListViewItem := ListViewContacts.Items.Add; try ListViewItem.Data['Text1'] := Contact.DisplayName; // 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.Text := Contact.DisplayName; //ListViewItem.Text2:= Contact.Phones; ListViewItem.Tag := Contact.ID; ``` |
AW: How do I extract the array of contact telephone numbers using Delphi FMX TAddres
You obviously can't, since that would be a clear violation of the data privacy regulations. It would require your phone to be rooted in order to access such sensitive information.
|
AW: How do I extract the array of contact telephone numbers using Delphi FMX TAddres
You just ask permission first. (Allow app to access contacts)
|
AW: How do I extract the array of contact telephone numbers using Delphi FMX TAddres
Hi,
the function is available I just can't work out the syntax of extracting the numbers. ![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:27 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz