Jump to content
Sign in to follow this  
Ranja AZ

How to send and intercept USSD result

Recommended Posts

Hello!

 

Please, I need help about sending and receiving USSD: how will my program intercept the returned string.

 

Here is the code I am using for sending first USSD code:

 

unit UTestPhoneDialer;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  FMX.Platform, FMX.PhoneDialer, FMX.StdCtrls, FMX.Controls.Presentation,
  FMX.Edit, FMX.Memo.Types, FMX.ScrollBox, FMX.Memo;

type
  TForm1 = class(TForm)
    lblCarrierName: TLabel;
    lblISOCountryCode: TLabel;
    btnGetCarrierInfo: TButton;
    lblTelephoneNumber: TLabel;
    edtTelephoneNumber: TEdit;
    btnMakeCall: TButton;
    Memo1: TMemo;
    procedure btnGetCarrierInfoClick(Sender: TObject);
    procedure btnMakeCallClick(Sender: TObject);
  private
    { Déclarations privées }
    PhoneDialerService: IFMXPhoneDialerService;
  public
    { Déclarations publiques }
    constructor Create(AOwner: TComponent); override;
  end;

var
  Form1: TForm1;

implementation

 

{$R *.fmx}
{$R *.LgXhdpiPh.fmx ANDROID}

 

procedure TForm1.btnGetCarrierInfoClick(Sender: TObject);
begin
  { test whether the PhoneDialer services are supported on your device }
  if Assigned(PhoneDialerService) then
  begin
    { if yes, then update the labels with the retrieved information }
    lblCarrierName.Text := 'Carrier Name:  '  + PhoneDialerService.GetCarrier.GetCarrierName;
    lblISOCountryCode.Text := 'ISO Country Code: ' + PhoneDialerService.GetCarrier.GetIsoCountryCode;
  end;
end;

 

procedure TForm1.btnMakeCallClick(Sender: TObject);
begin
  { test whether the PhoneDialer services are supported on your device }
  if Assigned(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;
end;

 

constructor TForm1.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(PhoneDialerService));
end;

 

end.

 

After first calling, Then I would have to respond to the different USSD information. How do I do?

 

Regard!

Edited by Ranja AZ

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×