Skip to content

android, sms.send: Suggestion to use sendMultipartTextMessage instead of sendTextMessage #831

Open
@Konubinix

Description

@Konubinix

I was trying to send sms from plyer recently and struggled to understand why some of them did not work. I learned in the process that:

  1. sms are actually limited to 160 encoded characters,
  2. when they don't contains ascii characters, the message is utf-16 encoded hence the limit on the message becomes quite low.
  3. there are two methods provided by android.telephony.SmsManager
    1. divideMessage gets the message and returns an array of single sms messages
    2. sendMultipartTextMessage gets as input the array returned by divideMessage and sends several sms as if it was a single message

I realize that this is was happens behind the hood in the default sms app.

Image

You can see here that the application informs me that the message will be actually split in two and that I only have 20 characters left in my message.

When removing the ê, I can type more words before the application let me know of the limit.

Image

So, I tried replacing sms.sendTextMessage(recipient, None, message, None, None) by sms.sendMultipartTextMessage(recipient, None, sms.divideMessage(message), None, None)

And it worked like a charm. I don't have message silently failing anymore.

I'm asking therefore if a pull request doing just that would be accepted? I don't know anough about android and the sms world to tell if there are reasons not to do that.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions