当前位置: 编程技术>移动开发
利用smsmanager实现后台发送短信示例
来源: 互联网 发布时间:2014-10-22
本文导语: 代码如下:public void sendServiceSms(Context mContext,String content) {try {SmsManager manager = SmsManager.getDefault();PendingIntent sentIntent = PendingIntent.getBroadcast(mContext, 0,new Intent(SMS_SENT_TEST_ACTION), 0);manager.sendTextMessage("13912345670", null, content, sentIntent, null...
代码如下:
public void sendServiceSms(Context mContext,String content) {
try {
SmsManager manager = SmsManager.getDefault();
PendingIntent sentIntent = PendingIntent.getBroadcast(mContext, 0,
new Intent(SMS_SENT_TEST_ACTION), 0);
manager.sendTextMessage("13912345670", null, content, sentIntent, null);
} catch (Exception e) {
e.printStackTrace();
}
}
参数说明
sendTextMessage(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent):
destinationAddress:接收方的手机号码
scAddress:发送方的手机号码
text:信息内容
sentIntent:发送是否成功的回执,
DeliveryIntent:接收是否成功的回执。