Android交付消息错误的号码是工作

时间:2016-07-10 10:17:24

标签: android sms messaging

当我发送错误电话号码的消息时(例如=> 093485),消息已发送。实际上,消息未送达

为什么即使我向无效号码m发送短信,我也会收到ACTION_SMS_DELIVERED

  

我的发送消息方法:

        Intent sendIntent = new Intent(ACTION_SMS_SENT);
        sendIntent.putExtra(Helper.KEY_SIM_DELIVER, id);
        Intent deliverIntent = new Intent(ACTION_SMS_DELIVERED);
        deliverIntent.putExtra(Helper.KEY_SIM_DELIVER, id);

        PendingIntent piSent = PendingIntent.getBroadcast(S.context, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        PendingIntent piDelivered = PendingIntent.getBroadcast(S.context, 0, deliverIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        SmsManager smsManager = SmsManager.getDefault();

        int smsSize = 0;
        int length = message.length();

        if (length > MAX_SMS_MESSAGE_LENGTH) {

            ArrayList<String> messagelist = smsManager.divideMessage(message);
            ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
            ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>();

            for (int i = 0; i < smsSize; i++) {

                sentIntents.add(PendingIntent.getBroadcast(S.context, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT));
                deliveryIntents.add(PendingIntent.getBroadcast(S.context, 0, deliverIntent, PendingIntent.FLAG_UPDATE_CURRENT));
            }
            smsManager.sendMultipartTextMessage(phoneNumber, null, messagelist, sentIntents, deliveryIntents);

        } else {
            minesCredit(isPesians, phoneNumber);
            smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDelivered);
        }
  

DeliveryBroadcastReceiver

 public void onReceive(Context context, Intent intent) {

        String action = intent.getAction();
        Bundle extras = intent.getExtras();
        if (action.equals(ACTION_SMS_DELIVERED)) {

            switch (getResultCode()) {
                case Activity.RESULT_OK: {

                    String id = extras.getString(Helper.KEY_SIM_DELIVER);
                    Log.d(TAG, "SMS Delivered from =>" + id);

                    break;
                }
                case Activity.RESULT_CANCELED:
                    Log.d(TAG, "SMS not Delivered  =>");

                    break;
            }
        }

1 个答案:

答案 0 :(得分:1)

我认为这是网络问题。

要进行测试,您可以尝试在其他短信应用中启用送达报告,并在将短信发送到同一号码后检查您是否收到送达通知。

<强>化背景

发送报告只是从网络发回给您的短信,说明已发送短信...然后,Android会通知所有应用ACTION_SMS_DELIVERED意图。 如果网络发送短信说短信已经发送(即使是无效的号码),你也无能为力......