Added in API level 1
Deprecated in API level 4

SmsManager

class SmsManager
kotlin.Any
   ↳ android.telephony.gsm.SmsManager

Manages SMS operations such as sending data, text, and pdu SMS messages. Get this object by calling the static method SmsManager.getDefault().

Summary

Constants
static Int

Generic failure cause

static Int

Failed because service is currently unavailable

static Int

Failed because no pdu provided

static Int

Failed because radio was explicitly turned off

static Int

Free space (TS 51.011 10.5.3).

static Int

Received and read (TS 51.011 10.5.3).

static Int

Stored and sent (TS 51.011 10.5.3).

static Int

Received and unread (TS 51.011 10.5.3).

static Int

Stored and unsent (TS 51.011 10.5.3).

Public methods
ArrayList<String!>!

Divide a text message into several messages, none bigger than the maximum SMS message size.

static SmsManager!

Get the default instance of the SmsManager

Unit
sendDataMessage(destinationAddress: String!, scAddress: String!, destinationPort: Short, data: ByteArray!, sentIntent: PendingIntent!, deliveryIntent: PendingIntent!)

Send a data based SMS to a specific application port.

Unit
sendMultipartTextMessage(destinationAddress: String!, scAddress: String!, parts: ArrayList<String!>!, sentIntents: ArrayList<PendingIntent!>!, deliveryIntents: ArrayList<PendingIntent!>!)

Send a multi-part text based SMS.

Unit
sendTextMessage(destinationAddress: String!, scAddress: String!, text: String!, sentIntent: PendingIntent!, deliveryIntent: PendingIntent!)

Send a text based SMS.

Constants

RESULT_ERROR_GENERIC_FAILURE

Added in API level 1
static val RESULT_ERROR_GENERIC_FAILURE: Int

Deprecated: Use android.telephony.SmsManager.

Generic failure cause

Value: 1

RESULT_ERROR_NO_SERVICE

Added in API level 1
static val RESULT_ERROR_NO_SERVICE: Int

Deprecated: Use android.telephony.SmsManager.

Failed because service is currently unavailable

Value: 4

RESULT_ERROR_NULL_PDU

Added in API level 1
static val RESULT_ERROR_NULL_PDU: Int

Deprecated: Use android.telephony.SmsManager.

Failed because no pdu provided

Value: 3

RESULT_ERROR_RADIO_OFF

Added in API level 1
static val RESULT_ERROR_RADIO_OFF: Int

Deprecated: Use android.telephony.SmsManager.

Failed because radio was explicitly turned off

Value: 2

STATUS_ON_SIM_FREE

Added in API level 1
static val STATUS_ON_SIM_FREE: Int

Deprecated: Use android.telephony.SmsManager.

Free space (TS 51.011 10.5.3).

Value: 0

STATUS_ON_SIM_READ

Added in API level 1
static val STATUS_ON_SIM_READ: Int

Deprecated: Use android.telephony.SmsManager.

Received and read (TS 51.011 10.5.3).

Value: 1

STATUS_ON_SIM_SENT

Added in API level 1
static val STATUS_ON_SIM_SENT: Int

Deprecated: Use android.telephony.SmsManager.

Stored and sent (TS 51.011 10.5.3).

Value: 5

STATUS_ON_SIM_UNREAD

Added in API level 1
static val STATUS_ON_SIM_UNREAD: Int

Deprecated: Use android.telephony.SmsManager.

Received and unread (TS 51.011 10.5.3).

Value: 3

STATUS_ON_SIM_UNSENT

Added in API level 1
static val STATUS_ON_SIM_UNSENT: Int

Deprecated: Use android.telephony.SmsManager.

Stored and unsent (TS 51.011 10.5.3).

Value: 7

Public methods

divideMessage

Added in API level 1
fun divideMessage(text: String!): ArrayList<String!>!

Deprecated: Use android.telephony.SmsManager.

Divide a text message into several messages, none bigger than the maximum SMS message size.

Parameters
text String!: the original message. Must not be null.
Return
ArrayList<String!>! an ArrayList of strings that, in order, comprise the original message

getDefault

Added in API level 1
static fun getDefault(): SmsManager!

Deprecated: Use android.telephony.SmsManager.

Get the default instance of the SmsManager

Return
SmsManager! the default instance of the SmsManager

sendDataMessage

Added in API level 1
fun sendDataMessage(
    destinationAddress: String!,
    scAddress: String!,
    destinationPort: Short,
    data: ByteArray!,
    sentIntent: PendingIntent!,
    deliveryIntent: PendingIntent!
): Unit

Deprecated: Use android.telephony.SmsManager.

Send a data based SMS to a specific application port.

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 Short: the port to deliver the message to
data ByteArray!: the body of the message to send
sentIntent PendingIntent!: if not NULL this PendingIntent is broadcast when the message is sucessfully 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 applicaitons, which cause smaller number of SMS to be sent in checking period.
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").
Exceptions
java.lang.IllegalArgumentException if destinationAddress or data are empty

sendMultipartTextMessage

Added in API level 1
fun sendMultipartTextMessage(
    destinationAddress: String!,
    scAddress: String!,
    parts: ArrayList<String!>!,
    sentIntents: ArrayList<PendingIntent!>!,
    deliveryIntents: ArrayList<PendingIntent!>!
): Unit

Deprecated: Use android.telephony.SmsManager.

Send a multi-part text based SMS. The callee should have already divided the message into correctly sized parts by calling divideMessage.

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
parts ArrayList<String!>!: an ArrayList of strings that, in order, comprise the original message
sentIntents ArrayList<PendingIntent!>!: if not null, an ArrayList of PendingIntents (one for each message part) that is broadcast when the corresponding message part has been sent. 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 applicaitons, which cause smaller number of SMS to be sent in checking period.
deliveryIntents ArrayList<PendingIntent!>!: if not null, an ArrayList of PendingIntents (one for each message part) that is broadcast when the corresponding message part has been delivered to the recipient. The raw pdu of the status report is in the extended data ("pdu").
Exceptions
java.lang.IllegalArgumentException if destinationAddress or data are empty

sendTextMessage

Added in API level 1
fun sendTextMessage(
    destinationAddress: String!,
    scAddress: String!,
    text: String!,
    sentIntent: PendingIntent!,
    deliveryIntent: PendingIntent!
): Unit

Deprecated: Use android.telephony.SmsManager.

Send a text based SMS.

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: 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 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").
Exceptions
java.lang.IllegalArgumentException if destinationAddress or text are empty