Search code examples
androidsmsillegalargumentexceptionsmsmanager

send blank SMS with SmsManager.sendTextMessage method in android


I created an android app and one of its functions is to send SMS, when I try to send blank SMS it throws an exception.

Here is the code:

SmsManager sm=SmsManager.getDefault();
sm.sendTextMessage("9999", null, messageBody,sentPI, deliveredPI);

messageBody maybe empty string and maybe it is a string, previous method throws IllegalArgumentException when messageBody is empty string!

what can I do to send blank SMS?


Solution

  • After looking at the Documentation:

    This method:

    Throws

    IllegalArgumentException    if destinationAddress or text are empty