Question

I'm trying to send a text message from my Android application. Everything works fine, but some of the text are missing. Here is my code:

String phoneNumber = "99********";  //Masked the number intentionally.
String message = "";
message += "This is Prabha, and thanks for using my application. ";
message += "Hope you enjoy this application. ";
message += "If you face any problem or issue, you can report the issue to our ";
message += "official mail id: pbha701@yahoo.com.";

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

I am receiving the message, but it is not full. Some text are missing. I'm getting only the below text:

This is Prabha, and thanks for using my application. Hope you enjoy this application. If you face any problem or issue, you can report the issue to our officia

I've added the below permission in AndroidManifest.xml:

<uses-permission android:name="android.permission.SEND_SMS" />

I am not able to find why the remaining text are truncated. Should I add any other permission or any setting changes required? Any ideas or help will be appreciated.

Thanks.

Was it helpful?

Solution

You need to use sendMultipartTextMessage() method available in SmsManager class.

sendTextMessage() method available in SmsManager class can send a text message of length 160 characters only.

To send multi-part SMS, divide the message using divideMessage() method available in SmsManager class. Then send this parts as an parameter in sendMultipartTextMessage(), as shown below:

SmsManager smsManager = SmsManager.getDefault();
ArrayList<String> parts = smsManager.divideMessage(message); 
smsManager.sendMultipartTextMessage(phoneNumber, null, parts, null, null);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top