Mouvement Casuffit
Mouvement Casuffit

Reputation: 29

How to make a call using Intent in Delphi?

How can I do the same as the following code does, but using Delphi?

Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:0987654321"))
startActivity(intent);

Upvotes: 0

Views: 2087

Answers (1)

Dave Nottage
Dave Nottage

Reputation: 3602

This may help:

uses
  Androidapi.Helpers, Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.Net;

procedure Dial(const ANumber: string);
var
  LIntent: JIntent;
begin
  LIntent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_DIAL);
  if LIntent.resolveActivity(TAndroidHelper.Context.getPackageManager) <> nil then
  begin
    LIntent.setData(TJnet_Uri.JavaClass.parse(StringToJString('tel:' + ANumber)));
    TAndroidHelper.Context.startActivity(LIntent);
  end
  else
    ShowMessage('Cannot dial!');
end;

Upvotes: 3

Related Questions