
One of the demos included with Delphi XE7 Firemonkey is the PhoneDialer demo. The PhoneDialer demo demonstrates how to use the IFMXPhoneDialerService in FMX.PhoneDialer to access carrier information and launch a phone call. The demo is available in the Mobile Snippets directory as well as from the Embarcadero SourceForge repository. It supports both Android and IOS according to the documentation and is also available in Appmethod. The carrier information that it shows is GetCarrierName, GetIsoCountryCode, GetMobileCountryCode, and GetMobileNetwork. And the Call functionality is as simple as passing the phone number string to the Call() function of the service. You can check out the two code snippets from the demo for accessing the carrier info and making a call below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
procedure TPhoneDialerForm.btnGetCarrierInfoClick(Sender: TObject); var PhoneDialerService: IFMXPhoneDialerService; begin { test whether the PhoneDialer services are supported } if TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(PhoneDialerService)) then begin { if yes, then update the labels with the retrieved information } CarrierNameItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetCarrierName; CountryCodeItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetIsoCountryCode; NetworkCodeItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetMobileCountryCode; MobileNetworkItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetMobileNetwork; end else ShowMessage('PhoneDialer service not supported'); end; procedure TPhoneDialerForm.btnMakeCallClick(Sender: TObject); var PhoneDialerService: IFMXPhoneDialerService; begin { test whether the PhoneDialer services are supported } if TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(PhoneDialerService)) then begin { if the Telephone Number is entered in the edit box then make the call, else display an error message } if edtTelephoneNumber.Text <> '' then PhoneDialerService.Call(edtTelephoneNumber.Text) else begin ShowMessage('Please type in a telephone number.'); edtTelephoneNumber.SetFocus; end; end else ShowMessage('PhoneDialer service not supported'); end; |