FMX.AddressBook.Types.TContactPhones.AddPhone
Delphi
function AddPhone(const AKind: TContactPhone.TLabelKind; const ANumber: string): TContactPhone; overload;
function AddPhone(const ALabel: string; const ANumber: string): TContactPhone; overload;
C++
TContactPhone* __fastcall AddPhone(const TContactPhone::TLabelKind AKind, const System::UnicodeString ANumber)/* overload */;
TContactPhone* __fastcall AddPhone(const System::UnicodeString ALabel, const System::UnicodeString ANumber)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | FMX.AddressBook.Types.pas FMX.AddressBook.Types.hpp |
FMX.AddressBook.Types | TContactPhones |
Description
Adds a new phone to a list of the contact phone numbers.
Use this method to add a new phone to a list of the contact phone numbers. The input parameters of this method allows you to specify the following characteristics:
ANumber
: specifies the contact phone, such as +1-185-100-1650'.AKind
: in the first overloaded method, this parameter specifies the kind of the contact phone.Alabel
: in the second overloaded method, this parameter specifies an optional text label, such as "Home," "FaxWork," and like.
Examples
To clarify, consider the following examples. These code snippets illustrate how to specify the contact mobile phone number, and save this contact to Address Book.
Delphi:
var
Contact: TAddressBookContact;
Phones: TContactPhones;
begin
Contact := AddressBook1.CreateContact(AddressBook1.DefaultSource);
try
// Add a mobile phone number
Phones := TContactPhones.Create;
try
Phones.AddPhone(TContactPhone.TLabelKind.Mobile, '+33-6-46-51-3531');
Contact.Phones := Phones;
finally
Phones.Free;
end;
// Save the newly created contact
AddressBook1.SaveContact(Contact);
finally
Contact.Free;
end;
end;
C++Builder:
TAddressBookContact *Contact;
TContactAddresses *addresses;
// Create a new contact
Contact = AddressBook1->CreateContact(AddressBook1->DefaultSource());
__try {
// Add the mobile phone number to the newly created contact
phones = new TContactPhones();
__try {
phones->AddPhone(TContactPhone::TLabelKind::Mobile,
"+33-6-46-51-3531");
Contact->Phones = phones;
}
__finally {
phones->Free();
}
// Save contact to Address Book
AddressBook1->SaveContact(Contact);
}
__finally {
Contact->Free();
}
For more information and samples, see Mobile Tutorial: Using an Address Book Component (iOS and Android).