Search code examples
androidsmsbroadcastreceiversmsmanager

android: how often can I send SMS message


Sending SMS by the:

SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, sentPI, null);

is buffered by the system?
Can I send next SMS in the same way inmediately, or I must wait for:

PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);  

registerReceiver(new BroadcastReceiver(){
    @Override
    public void onReceive(Context arg0, Intent arg1) {
        switch (getResultCode())
        {   case Activity.RESULT_OK:
//              ***next SMS ready to SEND***
                break;
            case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                break;
            case SmsManager.RESULT_ERROR_NO_SERVICE:
                break;
            case SmsManager.RESULT_ERROR_NULL_PDU:
                break;
            case SmsManager.RESULT_ERROR_RADIO_OFF:
                break;
        }
    }
}, new IntentFilter(SENT));

Solution

  • You can send multiple SMS without waiting for the SENT/DELIVERD callbacks. However, to prevent using the device to send spam SMS, most implementations of the SmsManager only permit X messages within a period of time Y. To prevent this protection mechanism from kicking in, you should not send lot of messages within a short period of time.

    If you want to send 2 or 3 messages back-to-back, this isn't a problem. But if you are sending dozens or hunreds, then you should probably add a time delay of 30 to 60 seconds in between each one.

    Be aware that the implementation of this behaviour can be different for each hardware vendor.