Codelord
Codelord

Reputation: 1120

How to limit or check SMS length so we can send Multi part SMS in android

I am trying to send SMS from android application. But because its length size I didn't know how many SMS can send in multi part. I just know 7-bit we can send 160 length and 8-bit 140 length and for 16-bit it is 70 length. But I need how I can know before sending SMS that is crossing its current length so I can restrict user to enter more than its limit.

Upvotes: 2

Views: 472

Answers (1)

David Wasser
David Wasser

Reputation: 95636

You can call SmsManager.divideMessage() to determine if the message will need to be split into multiple parts:

    SmsManager manager = SmsManager.getDefault();
    ArrayList<String> messageParts = manager.divideMessage(smsMessage);
    if (messageParts.size() > 1) {
        ... Message must be sent as more than one SMS
    }

See http://developer.android.com/reference/android/telephony/SmsManager.html#divideMessage%28java.lang.String%29

Upvotes: 1

Related Questions