Delphi FMX Android app. How to open SMS window

后端 未结 2 770
北恋
北恋 2021-01-23 20:02

How I can open Short Message Service (SMS) window on Android phode with pretyped message text and recipient number.

In manuals i found only Phone dialer



        
2条回答
  •  天命终不由人
    2021-01-23 20:52

    See the class SMSManager on Android API.

    There is a sendTextMessage method that you can use:

    Try some code like this:

    uses
      Androidapi.Helpers,
      Androidapi.JNI.JavaTypes, 
      Androidapi.JNI.Telephony;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      destAdress: JString;
      smsManager: JSmsManager;
    begin
      smsManager := TJSmsManager.JavaClass.getDefault;
      destAdress := StringToJString('0034123456789');
      smsManager.sendTextMessage(destAdress, nil, StringToJString('The message content'), nil, nil);
    end;
    

    You must add permissions to the project configuration. See the "Send SMS":

    Send SMS - Allows an application to send SMS messages.

    Regards.

提交回复
热议问题