分享

短信发送

 天天new 2013-06-04
SmsManager manager=SmsManager.getDefault();
ArrayList<String> texts=manager.divideMessage(ctn);//存放多条短信
for(String msg:texts)
{
manager.sendTextMessage(number, null,texts,null,null)
}

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

Since: API Level 4

Send a text based SMS.

Parameters
destinationAddress发送短信的地址(也就是号码)
scAddress短信服务中心,如果为null,就是用当前默认的短信服务中心
text短信内容
sentIntent如果不为null,当短信发送成功或者失败时,这个PendingIntent会被广播出去成功的结果代码是Activity.RESULT_OK,或者下面这些错误之一  :RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
对于 RESULT_ERROR_GENERIC_FAILURE,  the这个sentIntent可能包括额外的"errorCode",包含一些具体有用的信息帮助检查 。基于SMS控制的全部程序检查 sentIntent. 如果 sentIntent 为空,the caller will be checked against all unknown applications, which cause smaller number of SMS to be sent in checking period.
deliveryIntent如果不为null,当这个短信发送到接收者那里,这个PendtingIntent会被广播,状态报告生成的pdu(指对等层次之间传递的数据单位)会拓展到数据("pdu")

Manifest:
<users-permission android:name="android:permission.SEND_SMS"/>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多