如何判断android 短信发送是否成功
展开全部
private void mySendMessage(String phoneNum, String content) {
String SENT_SMS_ACTION = "SENT_SMS_ACTION";
Intent sentIntent = new Intent(SENT_SMS_ACTION);
PendingIntent sentPI = PendingIntent.getBroadcast(
context.getApplicationContext(), 0, sentIntent, 0);
// register the Broadcast Receivers
context.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context _context, Intent _intent) {
switch (getResultCode()) {
case Activity.RESULT_OK:
handler.sendEmptyMessage(Mark.SMS_SUCCESS);
//成功 下面的都是不成功山薯亩手铅
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
case SmsManager.RESULT_ERROR_RADIO_OFF:
case SmsManager.RESULT_ERROR_NULL_PDU:
handler.sendEmptyMessage(Mark.SMS_FAIL);
break;
default:
handler.sendEmptyMessage(Mark.SMS_FAIL);
break;
}
}
}, new IntentFilter(SENT_SMS_ACTION));
// 直接调用短信接逗森口发短信
SmsManager smsManager = SmsManager.getDefault();
List<String> divideContents = smsManager.divideMessage(content);
for (String text : divideContents) {
smsManager.sendTextMessage(phoneNum, null, text, sentPI, null);
}
}
String SENT_SMS_ACTION = "SENT_SMS_ACTION";
Intent sentIntent = new Intent(SENT_SMS_ACTION);
PendingIntent sentPI = PendingIntent.getBroadcast(
context.getApplicationContext(), 0, sentIntent, 0);
// register the Broadcast Receivers
context.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context _context, Intent _intent) {
switch (getResultCode()) {
case Activity.RESULT_OK:
handler.sendEmptyMessage(Mark.SMS_SUCCESS);
//成功 下面的都是不成功山薯亩手铅
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
case SmsManager.RESULT_ERROR_RADIO_OFF:
case SmsManager.RESULT_ERROR_NULL_PDU:
handler.sendEmptyMessage(Mark.SMS_FAIL);
break;
default:
handler.sendEmptyMessage(Mark.SMS_FAIL);
break;
}
}
}, new IntentFilter(SENT_SMS_ACTION));
// 直接调用短信接逗森口发短信
SmsManager smsManager = SmsManager.getDefault();
List<String> divideContents = smsManager.divideMessage(content);
for (String text : divideContents) {
smsManager.sendTextMessage(phoneNum, null, text, sentPI, null);
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
摩杜云
2024-07-09 广告
2024-07-09 广告
一个好的发送邮件api公司,不只是看价格,还要考虑很多因素。建议可以多找几个比对一下。您可以到摩杜云了解下。摩杜云成立于2019年,依托于公司多年技术沉淀和强大的云计算研发实力,面向全世界各个国家和地区、企业组织和个人开发者,提供全球的云计...
点击进入详情页
本回答由摩杜云提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询