SmsManager.SendDataMessage Method

Definition

Send a data based SMS to a specific application port.

[Android.Runtime.Register("sendDataMessage", "(Ljava/lang/String;Ljava/lang/String;S[BLandroid/app/PendingIntent;Landroid/app/PendingIntent;)V", "")]
public void SendDataMessage (string? destinationAddress, string? scAddress, short destinationPort, byte[]? data, Android.App.PendingIntent? sentIntent, Android.App.PendingIntent? deliveryIntent);
[<Android.Runtime.Register("sendDataMessage", "(Ljava/lang/String;Ljava/lang/String;S[BLandroid/app/PendingIntent;Landroid/app/PendingIntent;)V", "")>]
member this.SendDataMessage : string * string * int16 * byte[] * Android.App.PendingIntent * Android.App.PendingIntent -> unit

Parameters

destinationAddress
String

the address to send the message to

scAddress
String

is the service center address or null to use the current default SMSC

destinationPort
Int16

the port to deliver the message to

data
Byte[]

the body of the message to send

sentIntent
PendingIntent

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:<br> RESULT_ERROR_GENERIC_FAILURE<br> RESULT_ERROR_RADIO_OFF<br> RESULT_ERROR_NULL_PDU<br> RESULT_ERROR_NO_SERVICE<br> RESULT_ERROR_LIMIT_EXCEEDED<br> RESULT_ERROR_FDN_CHECK_FAILURE<br> RESULT_ERROR_SHORT_CODE_NOT_ALLOWED<br> RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED<br> RESULT_RADIO_NOT_AVAILABLE<br> RESULT_NETWORK_REJECT<br> RESULT_INVALID_ARGUMENTS<br> RESULT_INVALID_STATE<br> RESULT_NO_MEMORY<br> RESULT_INVALID_SMS_FORMAT<br> RESULT_SYSTEM_ERROR<br> RESULT_MODEM_ERROR<br> RESULT_NETWORK_ERROR<br> RESULT_ENCODING_ERROR<br> RESULT_INVALID_SMSC_ADDRESS<br> RESULT_OPERATION_NOT_ALLOWED<br> RESULT_INTERNAL_ERROR<br> RESULT_NO_RESOURCES<br> RESULT_CANCELLED<br> RESULT_REQUEST_NOT_SUPPORTED<br> RESULT_NO_BLUETOOTH_SERVICE<br> RESULT_INVALID_BLUETOOTH_ADDRESS<br> RESULT_BLUETOOTH_DISCONNECTED<br> RESULT_UNEXPECTED_EVENT_STOP_SENDING<br> RESULT_SMS_BLOCKED_DURING_EMERGENCY<br> RESULT_SMS_SEND_RETRY_FAILED<br> RESULT_REMOTE_EXCEPTION<br> RESULT_NO_DEFAULT_SMS_APP<br> RESULT_RIL_RADIO_NOT_AVAILABLE<br> RESULT_RIL_SMS_SEND_FAIL_RETRY<br> RESULT_RIL_NETWORK_REJECT<br> RESULT_RIL_INVALID_STATE<br> RESULT_RIL_INVALID_ARGUMENTS<br> RESULT_RIL_NO_MEMORY<br> RESULT_RIL_REQUEST_RATE_LIMITED<br> RESULT_RIL_INVALID_SMS_FORMAT<br> RESULT_RIL_SYSTEM_ERR<br> RESULT_RIL_ENCODING_ERR<br> RESULT_RIL_INVALID_SMSC_ADDRESS<br> RESULT_RIL_MODEM_ERR<br> RESULT_RIL_NETWORK_ERR<br> RESULT_RIL_INTERNAL_ERR<br> RESULT_RIL_REQUEST_NOT_SUPPORTED<br> RESULT_RIL_INVALID_MODEM_STATE<br> RESULT_RIL_NETWORK_NOT_READY<br> RESULT_RIL_OPERATION_NOT_ALLOWED<br> RESULT_RIL_NO_RESOURCES<br> RESULT_RIL_CANCELLED<br> RESULT_RIL_SIM_ABSENT<br> RESULT_RIL_SIMULTANEOUS_SMS_AND_CALL_NOT_ALLOWED<br> RESULT_RIL_ACCESS_BARRED<br> RESULT_RIL_BLOCKED_DUE_TO_CALL<br> For RESULT_ERROR_GENERIC_FAILURE or any of the RESULT_RIL errors, the sentIntent may include the extra "errorCode" containing a radio technology specific value, generally only useful for troubleshooting.<br>

deliveryIntent
PendingIntent

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").

Attributes

Exceptions

if destinationAddress or data are empty

Remarks

Send a data based SMS to a specific application port.

<p class="note"><strong>Note:</strong> Using this method requires that your app has the android.Manifest.permission#SEND_SMS permission.</p>

<p class="note"><strong>Note:</strong> If #getDefault() is used to instantiate this manager on a multi-SIM device, this operation may fail sending the SMS message because no suitable default subscription could be found. In this case, if sentIntent is non-null, then the PendingIntent will be sent with an error code RESULT_ERROR_GENERIC_FAILURE and an extra string "noDefault" containing the boolean value true. See #getDefault() for more information on the conditions where this operation may fail. </p>

Java documentation for android.telephony.SmsManager.sendDataMessage(java.lang.String, java.lang.String, short, byte[], android.app.PendingIntent, android.app.PendingIntent).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to