1

I'm trying to send a USSD code for example *1411# but the problem is the # symbol gets removed and the phone will dial to *1411 not *1411#

  if Assigned(PhoneDialerService) then
  begin
    if edtCardNumber.Text <> '' then
      PhoneDialerService.Call('*1411#')
    else
      ShowMessage('Error');
  end;

If the PhoneDialerService.Call can't send USSD code what alternative do I use instead?

Johan
  • 74,508
  • 24
  • 191
  • 319
RepeatUntil
  • 2,272
  • 4
  • 32
  • 57

1 Answers1

1

i found it :)

  if Assigned(PhoneDialerService) then
  begin
    if edtCardNumber.Text <> '' then
      PhoneDialerService.Call('*1411'+JStringToString(TJnet_Uri.JavaClass.encode(StringToJString('#'))))
    else
    begin
      ShowMessage('Error');
      edtCardNumber.SetFocus;
    end;
  end;
RepeatUntil
  • 2,272
  • 4
  • 32
  • 57
  • +1, well done; do you happen to have a link where you found that info? – Johan May 03 '14 at 20:26
  • @Johan see in this [link](http://stackoverflow.com/questions/5477597/how-is-it-possible-to-do-ussd-requests-on-android) in jave programming they use `String encodedHash = Uri.encode("#");` then i try to use the 'Uri.encode' in delphi :) – RepeatUntil May 03 '14 at 21:37
  • 1
    Since you are hard-coding the number, you can hard-code the encoding as well, to avoid all the redundant conversions and allocations: `PhoneDialerService.Call('*1411%23');` – Remy Lebeau May 05 '14 at 00:56