利用smsmanager实现后台发送短信示例
程序员文章站
2023-11-14 08:29:52
复制代码 代码如下:public void sendservicesms(context mcontext,string content) {try {smsmanager...
复制代码 代码如下:
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:接收是否成功的回执。