如何在Delphi中使用Intent拨打电话?

时间:2019-03-07 10:06:29

标签: android delphi android-intent mobile call

除了使用Delphi之外,如何与以下代码相同?

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

1 个答案:

答案 0 :(得分:2)

这可能有帮助:

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;