再次发送短信错误,通用失败,再次出现

编程入门 行业动态 更新时间:2024-10-10 17:28:56
本文介绍了再次发送短信错误,通用失败,再次出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我的代码.

private void sendSMS(String phoneNumber, String message) { String SENT = "SMS_SENT"; String DELIVERED = "SMS_DELIVERED"; PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent( SENT), 0); PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0); // ---when the SMS has been sent--- registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context arg0, Intent arg1) { switch (getResultCode()) { case Activity.RESULT_OK: ContentValues values = new ContentValues(); //for (int i = 0; i < MobNumber.size() - 1; i++) { // values.put("address", MobNumber.get(i).toString());// txtPhoneNo.getText().toString()); // values.put("body", MessageText.getText().toString()); //} getContentResolver().insert( Uri.parse("content://sms/sent"), values); Toast.makeText(getBaseContext(), "SMS sent", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_GENERIC_FAILURE: Toast.makeText(getBaseContext(), "Generic failure", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_NO_SERVICE: Toast.makeText(getBaseContext(), "No service", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_NULL_PDU: Toast.makeText(getBaseContext(), "Null PDU", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_RADIO_OFF: Toast.makeText(getBaseContext(), "Radio off", Toast.LENGTH_SHORT).show(); break; } } }, new IntentFilter(SENT)); // ---when the SMS has been delivered--- registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context arg0, Intent arg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS delivered", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not delivered", Toast.LENGTH_SHORT).show(); break; } } }, new IntentFilter(DELIVERED)); SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI); }

我一次没有发送太多短信.我没有很快寄出.该代码正在扩展AppCompactActivity的活动中.我已经在该网站上阅读了有关此错误的所有链接.我什至无法发送短信.我的手机帐户余额足以发送短信.我的网络服务也很好,我可以发送和接收短信.刚收到一个错误"Generic failure".如果有人有任何想法,请帮助我.

I am not sending so many SMSs at a time. I am not sending it fast. This code is under activity which extends AppCompactActivity. I have read all the links about this error on this site. I can't even send one sms. My mobile account balance is enough to send sms. My network service is also fine and I can send and receive sms. just getting one error "Generic failure". Please help me if any one have any idea.

推荐答案

我认为您需要检查邮件中心号码.如果未设置或正确,则可能发生此故障.您会在SMS设置选项中找到该号码.

I think you need to check the message center number. If it is not set or correct than this failure may happen. You will found this number at the SMS settings option.

更多推荐

再次发送短信错误,通用失败,再次出现

本文发布于:2023-10-27 23:48:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534885.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送短信   错误

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!