Most visited

Recently visited

Added in API level 1
Deprecated since API level 4

SmsManager

public final class SmsManager
extends Object

java.lang.Object
   ↳ android.telephony.gsm.SmsManager


此类已在API级别4中弃用。
由支持GSM和CDMA的android.telephony.SmsManager取代。

管理SMS操作,例如发送数据,文本和pdu SMS消息。 通过调用静态方法SmsManager.getDefault()来获取此对象。

Summary

Constants

int RESULT_ERROR_GENERIC_FAILURE

此常数在API级别4中已被弃用。使用android.telephony.SmsManager。

int RESULT_ERROR_NO_SERVICE

此常数在API级别4中已被弃用。使用android.telephony.SmsManager。

int RESULT_ERROR_NULL_PDU

此常数在API级别4中已被弃用。使用android.telephony.SmsManager。

int RESULT_ERROR_RADIO_OFF

此常数在API级别4中已被弃用。使用android.telephony.SmsManager。

int STATUS_ON_SIM_FREE

此常数在API级别4中已被弃用。使用android.telephony.SmsManager。

int STATUS_ON_SIM_READ

此常数在API级别4中已被弃用。使用android.telephony.SmsManager。

int STATUS_ON_SIM_SENT

此常数在API级别4中已被弃用。使用android.telephony.SmsManager。

int STATUS_ON_SIM_UNREAD

此常数在API级别4中已被弃用。使用android.telephony.SmsManager。

int STATUS_ON_SIM_UNSENT

此常数在API级别4中已被弃用。使用android.telephony.SmsManager。

Public methods

final ArrayList<String> divideMessage(String text)

此方法在API级别4中已弃用。使用android.telephony.SmsManager。

static final SmsManager getDefault()

此方法在API级别4中已弃用。使用android.telephony.SmsManager。

final void sendDataMessage(String destinationAddress, String scAddress, short destinationPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent)

此方法在API级别4中已弃用。使用android.telephony.SmsManager。

final void sendMultipartTextMessage(String destinationAddress, String scAddress, ArrayList<String> parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents)

此方法在API级别4中已弃用。使用android.telephony.SmsManager。

final void sendTextMessage(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)

此方法在API级别4中已弃用。使用android.telephony.SmsManager。

Inherited methods

From class java.lang.Object

Constants

RESULT_ERROR_GENERIC_FAILURE

Added in API level 1
int RESULT_ERROR_GENERIC_FAILURE

此常数在API级别4中已弃用。
使用android.telephony.SmsManager。

通用故障原因

常数值:1(0x00000001)

RESULT_ERROR_NO_SERVICE

Added in API level 1
int RESULT_ERROR_NO_SERVICE

此常数在API级别4中已弃用。
使用android.telephony.SmsManager。

因服务当前不可用而失败

常量值:4(0x00000004)

RESULT_ERROR_NULL_PDU

Added in API level 1
int RESULT_ERROR_NULL_PDU

此常数在API级别4中已弃用。
使用android.telephony.SmsManager。

因为没有提供pdu而失败

常量值:3(0x00000003)

RESULT_ERROR_RADIO_OFF

Added in API level 1
int RESULT_ERROR_RADIO_OFF

此常数在API级别4中已弃用。
使用android.telephony.SmsManager。

因无线电被明确关闭而失败

常量值:2(0x00000002)

STATUS_ON_SIM_FREE

Added in API level 1
int STATUS_ON_SIM_FREE

此常数在API级别4中已弃用。
使用android.telephony.SmsManager。

可用空间(TS 51.011 10.5.3)。

常量值:0(0x00000000)

STATUS_ON_SIM_READ

Added in API level 1
int STATUS_ON_SIM_READ

此常数在API级别4中已弃用。
使用android.telephony.SmsManager。

收到并阅读(TS 51.011 10.5.3)。

常数值:1(0x00000001)

STATUS_ON_SIM_SENT

Added in API level 1
int STATUS_ON_SIM_SENT

此常数在API级别4中已弃用。
使用android.telephony.SmsManager。

存储并发送(TS 51.011 10.5.3)。

常量值:5(0x00000005)

STATUS_ON_SIM_UNREAD

Added in API level 1
int STATUS_ON_SIM_UNREAD

此常数在API级别4中已弃用。
使用android.telephony.SmsManager。

已收到和未读(TS 51.011 10.5.3)。

常量值:3(0x00000003)

STATUS_ON_SIM_UNSENT

Added in API level 1
int STATUS_ON_SIM_UNSENT

此常数在API级别4中已弃用。
使用android.telephony.SmsManager。

存储和未发送(TS 51.011 10.5.3)。

常量值:7(0x00000007)

Public methods

divideMessage

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

此方法在API级别4中已弃用。
使用android.telephony.SmsManager。

将短信分成几条短信,不能超过最大短信大小。

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

getDefault

Added in API level 1
SmsManager getDefault ()

此方法在API级别4中已弃用。
使用android.telephony.SmsManager。

获取SmsManager的默认实例

Returns
SmsManager the default instance of the SmsManager

sendDataMessage

Added in API level 1
void sendDataMessage (String destinationAddress, 
                String scAddress, 
                short destinationPort, 
                byte[] data, 
                PendingIntent sentIntent, 
                PendingIntent deliveryIntent)

此方法在API级别4中已弃用。
使用android.telephony.SmsManager。

将基于数据的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
destinationPort short: 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 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").
Throws
IllegalArgumentException if destinationAddress or data are empty

sendMultipartTextMessage

Added in API level 1
void sendMultipartTextMessage (String destinationAddress, 
                String scAddress, 
                ArrayList<String> parts, 
                ArrayList<PendingIntent> sentIntents, 
                ArrayList<PendingIntent> deliveryIntents)

此方法在API级别4中已弃用。
使用android.telephony.SmsManager。

发送基于短信的多部分文字。 被叫方应该已经通过调用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: an ArrayList of strings that, in order, comprise the original message
sentIntents ArrayList: 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: 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").
Throws
IllegalArgumentException if destinationAddress or data are empty

sendTextMessage

Added in API level 1
void sendTextMessage (String destinationAddress, 
                String scAddress, 
                String text, 
                PendingIntent sentIntent, 
                PendingIntent deliveryIntent)

此方法在API级别4中已弃用。
使用android.telephony.SmsManager。

发送基于文本的短信。

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").
Throws
IllegalArgumentException if destinationAddress or text are empty

Hooray!