RAD Studio XE8 The phone's dialing function in the app

Source: Internet
Author: User

1, new Muilti Device C + + Builder project, add 2 header files in. h:#include <fmx. Platform.hpp>#include <fmx. Phonedialer.hpp>2. Add Private declaration variable: _di_ifmxphonedialerservice phonedialerservice; (No add *, but type is pointer)__published declaration method: void __fastcall myoncallstatechanged (const unicodestring acallid,const tcallstate aCallState); 3, add the control to display, at this time the Edit to be used as a dial pad, so to setKeyboardtype = NumberpadReturnkeytype = GoKillfocusbyreturn = True4. In. cpp, write code for 2 buttons://Get carrier information, displayed in Label1 and Label2void __fastcall Tform3::button1click (tobject *sender)
{
this->label1->text=phonedialerservice->getcarrier ()->getcarriername ();
this->label2->text=phonedialerservice->getcarrier ()->getisocountrycode ();
}//Follow the number in the Edit to Dial
void __fastcall Tform3::button2click (tobject *sender)
{
Phonedialerservice->call (this->edit1->text);
}5. Write the code for the new method myoncallstatechanged:void __fastcall tform3::myoncallstatechanged (const unicodestring Acallid,
Const tcallstate acallstate)
 {
switch (acallstate) {
Case Tcallstate::none:
label3->text= "" +acallid;
Break ;
Case tcallstate::connected:
Label3->text=l "There is a call" +acallid;
Break ;
Case tcallstate::D ialing:
label3->text=l "dialing" +ACALLID;
Break ;
Case tcallstate::D isconnected:
label3->text=l "Disconnect" +acallid;
Break ;
   }
 }6. Click the OnCreate event in the events section of the form to write the code:void __fastcall tform3::formcreate (tobject *sender)
{
Phonedialerservice=tplatformservices::current->getplatformservice (__uuidof (IFMXPhoneDialerService));
phonedialerservice->oncallstatechanged=myoncallstatechanged;
}7, after installing on the phone, enter the phone number in the dial pad, such as 10086, click to dial. Click on the 2 button, the contents of the first two labels can display the operator's name and code.

RAD Studio XE8 The phone's dialing function in the app

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.