14

I've got an app that lets users send sms messages. Works great when the message < 160 characters. After that, things work less-perfectly. Seems like there are a few options here:

  1. Manually break the message up into multiple SMSs, send each part as a separate SMS.
  2. Use the multi-part send SMS function (sendMultipartTextMessage()).
  3. Send the message as an MMS message (sendDataMessage()?).

Here's my novice take on it:

1) most well supported across carriers. Users may get mad that you just cost them N separate messages though, instead of converting to MMS or something.

2) not sure if this is supported by different carriers, and read that once the message is greater than 3 * 160 chars in length, gets converted to MMS anyway by different SMS apps - maybe stay away from this altogether.

3) not sure how to do this, and older phones might not support MMS. To send an MMS using the android SDK, do we just use the SmsManager.sendDataMessage() method?

Thanks

Mark
  • 39,551
  • 15
  • 41
  • 47

3 Answers3

40

This is quite an old post but it's high up on Google when searching for Android multipart sms, so maybe it helps someone.

Regarding part 1 and 2, it's pretty much the same thing. To use sendMultipartTextMessage, you need to break up the long message into an ArrayList of Strings. It then sends as many SMS as needed. In short:

SmsManager sms = SmsManager.getDefault();
ArrayList<String> parts = sms.divideMessage(longMessage);
sms.sendMultipartTextMessage(phoneNumber, null, parts, null, null);

Part 3: MMS is not an option, as it has been pointed out. The charges and all.

Valentin Klinghammer
  • 1,319
  • 1
  • 13
  • 19
  • I've just tried out your solution: it just doesnt work, event no error in the log, any suggestion ? Tks – hungson175 Dec 16 '11 at 08:28
  • Ah, sorry, I filled in the wrong number :). The solution work nicely ! Tks – hungson175 Dec 16 '11 at 09:11
  • Some carriers (this occurred with Sprint on CDMA) modify Android that they don't reassemble the message! This is actually an issue we have to deal with. And the solution is not trivial as I have to check how the message is segmented. – allprog May 22 '12 at 18:57
1

seems to me that the first option is what most mobile phones do by default. sms messages by design can only send a certain amount of characters (160 probbaly), just inform the user that the message is too big and if he still wants to send it anyway (informing also how many sms would the total be).

as for MMS and multipart as you said not every carrier supports it, so they dont seem to be the best option.

EDIT: as for how does MMS work on android-sdk check this thread out: Android SDK MMS

Community
  • 1
  • 1
sap
  • 1,188
  • 1
  • 14
  • 25
  • 1
    I agree. An alert notifying that the message is too long and will have to be sent as n text messages with an accept/cancel option seems like the best choice to me. – Vian Esterhuizen Dec 30 '09 at 17:56
  • 2
    What country are you in? I would be surprised to hear of carriers that don't support multipart SMS messages. I live in the UK and it's been nearly ten years since I last had a phone that didn't understand multipart SMS. I would doubt that many regular phones convert long SMS messages into an MMS (e.g. here I get free SMS, but MMS costs me money to send). – Christopher Orr Dec 31 '09 at 01:34
-1

I would suggest the usage of option 2 when you are working on Androids GSM based handsets.

GSM based Mobile device takes care of segmentation in which breaking the messages to multiparts for sending in performed and also assembling of the multipart messages in to one message on receipt.

If you have a method which takes care of sending text messages, than by default use the options of manager.divideMessage as it will work even if the message segments required are only 1 in number.

I dont think you should have any problem sending messages using option 2 and it will also ensure that the receiver receives the message as a single message. Else we need to write your our own protocol stack where in you write reference number and number of messages for the receipient to understand and recreate the complete message; which is not very tough. We can use byte arrays with headers and the messages can be sent as base64 encoded.

Also I dont know much about the limits the carriers enforce on the number of segments in multipart message; based on my test I was able to send and receive 160*8 segments properly. Based on the GSM standards the segments can be upto 255 but that count might depend on the service provider implementation.

Mohit Sethi
  • 191
  • 9
  • Android supports dividing long SMS messages into multiple parts and manages the sending of said mulit-part messages within the SMS api. – Phil Haigh Nov 10 '12 at 21:09