SmsManager.SendTextMessage Method

Definition

Overloads

SendTextMessage(String, String, String, PendingIntent, PendingIntent)

Send a text based SMS.

SendTextMessage(String, String, String, PendingIntent, PendingIntent, Int64)

Send a text based SMS.

SendTextMessage(String, String, String, PendingIntent, PendingIntent)

Send a text based SMS.

[Android.Runtime.Register("sendTextMessage", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/app/PendingIntent;Landroid/app/PendingIntent;)V", "")]
public void SendTextMessage (string? destinationAddress, string? scAddress, string? text, Android.App.PendingIntent? sentIntent, Android.App.PendingIntent? deliveryIntent);
[<Android.Runtime.Register("sendTextMessage", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/app/PendingIntent;Landroid/app/PendingIntent;)V", "")>]
member this.SendTextMessage : string * string * string * 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

text
String

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 text are empty

Remarks

Send a text based SMS.

<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> Beginning with Android 4.4 (API level 19), if <em>and only if</em> an app is not selected as the default SMS app, the system automatically writes messages sent using this method to the SMS Provider (the default SMS app is always responsible for writing its sent messages to the SMS Provider). For information about how to behave as the default SMS app, see android.provider.Telephony.</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.sendTextMessage(java.lang.String, java.lang.String, java.lang.String, 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

SendTextMessage(String, String, String, PendingIntent, PendingIntent, Int64)

Send a text based SMS.

[Android.Runtime.Register("sendTextMessage", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/app/PendingIntent;Landroid/app/PendingIntent;J)V", "", ApiSince=30)]
public void SendTextMessage (string destinationAddress, string? scAddress, string text, Android.App.PendingIntent? sentIntent, Android.App.PendingIntent? deliveryIntent, long messageId);
[<Android.Runtime.Register("sendTextMessage", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/app/PendingIntent;Landroid/app/PendingIntent;J)V", "", ApiSince=30)>]
member this.SendTextMessage : string * string * string * Android.App.PendingIntent * Android.App.PendingIntent * int64 -> 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

text
String

the body of the message to send

sentIntent
PendingIntent

if not NULL this <code>PendingIntent</code> is broadcast when the message is successfully sent, or failed. The result code will be <code>Activity.RESULT_OK</code> for success, or one of these errors:<br> <code>RESULT_ERROR_GENERIC_FAILURE</code><br> <code>RESULT_ERROR_RADIO_OFF</code><br> <code>RESULT_ERROR_NULL_PDU</code><br> <code>RESULT_ERROR_NO_SERVICE</code><br> <code>RESULT_ERROR_LIMIT_EXCEEDED</code><br> <code>RESULT_ERROR_FDN_CHECK_FAILURE</code><br> <code>RESULT_ERROR_SHORT_CODE_NOT_ALLOWED</code><br> <code>RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED</code><br> <code>RESULT_RADIO_NOT_AVAILABLE</code><br> <code>RESULT_NETWORK_REJECT</code><br> <code>RESULT_INVALID_ARGUMENTS</code><br> <code>RESULT_INVALID_STATE</code><br> <code>RESULT_NO_MEMORY</code><br> <code>RESULT_INVALID_SMS_FORMAT</code><br> <code>RESULT_SYSTEM_ERROR</code><br> <code>RESULT_MODEM_ERROR</code><br> <code>RESULT_NETWORK_ERROR</code><br> <code>RESULT_ENCODING_ERROR</code><br> <code>RESULT_INVALID_SMSC_ADDRESS</code><br> <code>RESULT_OPERATION_NOT_ALLOWED</code><br> <code>RESULT_INTERNAL_ERROR</code><br> <code>RESULT_NO_RESOURCES</code><br> <code>RESULT_CANCELLED</code><br> <code>RESULT_REQUEST_NOT_SUPPORTED</code><br> <code>RESULT_NO_BLUETOOTH_SERVICE</code><br> <code>RESULT_INVALID_BLUETOOTH_ADDRESS</code><br> <code>RESULT_BLUETOOTH_DISCONNECTED</code><br> <code>RESULT_UNEXPECTED_EVENT_STOP_SENDING</code><br> <code>RESULT_SMS_BLOCKED_DURING_EMERGENCY</code><br> <code>RESULT_SMS_SEND_RETRY_FAILED</code><br> <code>RESULT_REMOTE_EXCEPTION</code><br> <code>RESULT_NO_DEFAULT_SMS_APP</code><br> <code>RESULT_RIL_RADIO_NOT_AVAILABLE</code><br> <code>RESULT_RIL_SMS_SEND_FAIL_RETRY</code><br> <code>RESULT_RIL_NETWORK_REJECT</code><br> <code>RESULT_RIL_INVALID_STATE</code><br> <code>RESULT_RIL_INVALID_ARGUMENTS</code><br> <code>RESULT_RIL_NO_MEMORY</code><br> <code>RESULT_RIL_REQUEST_RATE_LIMITED</code><br> <code>RESULT_RIL_INVALID_SMS_FORMAT</code><br> <code>RESULT_RIL_SYSTEM_ERR</code><br> <code>RESULT_RIL_ENCODING_ERR</code><br> <code>RESULT_RIL_INVALID_SMSC_ADDRESS</code><br> <code>RESULT_RIL_MODEM_ERR</code><br> <code>RESULT_RIL_NETWORK_ERR</code><br> <code>RESULT_RIL_INTERNAL_ERR</code><br> <code>RESULT_RIL_REQUEST_NOT_SUPPORTED</code><br> <code>RESULT_RIL_INVALID_MODEM_STATE</code><br> <code>RESULT_RIL_NETWORK_NOT_READY</code><br> <code>RESULT_RIL_OPERATION_NOT_ALLOWED</code><br> <code>RESULT_RIL_NO_RESOURCES</code><br> <code>RESULT_RIL_CANCELLED</code><br> <code>RESULT_RIL_SIM_ABSENT</code><br> <code>RESULT_RIL_SIMULTANEOUS_SMS_AND_CALL_NOT_ALLOWED</code><br> <code>RESULT_RIL_ACCESS_BARRED</code><br> <code>RESULT_RIL_BLOCKED_DUE_TO_CALL</code><br> For <code>RESULT_ERROR_GENERIC_FAILURE</code> 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 <code>PendingIntent</code> is broadcast when the message is delivered to the recipient. The raw pdu of the status report is in the extended data ("pdu").

messageId
Int64

An id that uniquely identifies the message requested to be sent. Used for logging and diagnostics purposes. The id may be 0.

Attributes

Remarks

Send a text based SMS. Same as #sendTextMessage( String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent), but adds an optional messageId.

Java documentation for android.telephony.SmsManager.sendTextMessage(java.lang.String, java.lang.String, java.lang.String, android.app.PendingIntent, android.app.PendingIntent, long).

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