AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language How do I extract the array of contact telephone numbers using Delphi FMX TAddressboo
Thema durchsuchen
Ansicht
Themen-Optionen

How do I extract the array of contact telephone numbers using Delphi FMX TAddressboo

Ein Thema von Classic12 · begonnen am 5. Jun 2020 · letzter Beitrag vom 7. Jun 2020
Antwort Antwort
Classic12

Registriert seit: 5. Jun 2020
3 Beiträge
 
#1

How do I extract the array of contact telephone numbers using Delphi FMX TAddressboo

  Alt 5. Jun 2020, 10:15
Delphi-Version: 10.3 Rio
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;
```
  Mit Zitat antworten Zitat
Dennis07

Registriert seit: 19. Sep 2011
Ort: Deutschland
481 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: How do I extract the array of contact telephone numbers using Delphi FMX TAddres

  Alt 5. Jun 2020, 14:35
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.
Dennis
  Mit Zitat antworten Zitat
Classic12

Registriert seit: 5. Jun 2020
3 Beiträge
 
#3

AW: How do I extract the array of contact telephone numbers using Delphi FMX TAddres

  Alt 5. Jun 2020, 23:43
You just ask permission first. (Allow app to access contacts)
  Mit Zitat antworten Zitat
Classic12

Registriert seit: 5. Jun 2020
3 Beiträge
 
#4

AW: How do I extract the array of contact telephone numbers using Delphi FMX TAddres

  Alt 7. Jun 2020, 11:50
Hi,

the function is available I just can't work out the syntax of extracting the numbers.

http://docwiki.embarcadero.com/RADSt...OS_and_Android)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:54 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz