user2897240
user2897240

Reputation: 11

DELPHI XE5 How send SMS with delivery notification in ANDROID

I know how to send sms from Android. It's very simple:

var   
  smsTo: JString;
  smsManager: JSmsManager;
begin
  smsManager := TJSmsManager.JavaClass.getDefault;
  smsTo := StringToJString('number_xxx');
  smsManager.sendTextMessage(smsTo, nil, StringToJString('Test SMS'), nil, nil);

But the question is: How to send sms with delivery recipient? Is it possible in Delphi XE5?

Thanks for your answers. George

Upvotes: 1

Views: 1930

Answers (1)

Pateman
Pateman

Reputation: 2757

From the Android's documentation:

Parameters

  • destinationAddress the address to send the message to
  • scAddress is the service center address or null to use the current default SMSC
  • text the body of the message to send
  • sentIntent if not NULL this PendingIntent is broadcast when the message is successfully sent, or failed. The result code will be Activity.RESULT_OK for success, or one of these errors: RESULT_ERROR_GENERIC_FAILURE RESULT_ERROR_RADIO_OFF RESULT_ERROR_NULL_PDU. The per-application based SMS control checks sentIntent. If sentIntent is NULL the caller will be checked against all unknown applications, which cause smaller number of SMS to be sent in checking period.
  • deliveryIntent if not NULL this PendingIntent is broadcast when the message is delivered to the recipient. The raw pdu of the status report is in the extended data ("pdu").

You're clearly missing the last two parameters in your code.

Here's how to do that in Java - it's pretty straightforward, but Delphi makes in a bit harder for us. Have a look at the answer here. The most interesting thing is the first link in the answer.

Basically you need to use the JNI wrapper to communicate with Java classes directly, because Delphi doesn't expose the functionality needed here - at least I'm not aware of anything.

Good luck!

Upvotes: 1

Related Questions