再次发送短信错误,通用失败,再次出现 [英] Sending sms error Generic failure again and agian

查看:183
本文介绍了再次发送短信错误,通用失败,再次出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码.

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.

这篇关于再次发送短信错误,通用失败,再次出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆