Question

I am developing an application which will send sms directly from my application, here is the code iam using to send and sms, if i replace finalmessage with some character like "hello" it work fine.. but if i use finalmessage it will simply force close.. and one more thing finalmessage contains around 500 character. So i still dont understand what is the problem and why it getting force close.

SmsManager sm = SmsManager.getDefault();
PendingIntent sent = PendingIntent.getBroadcast(this, 0, new Intent(), 0);
PendingIntent delivered = PendingIntent.getBroadcast(this, 0, new Intent(), 0);
sm.sendTextMessage(stringnumber, null,finalmessage, sent, delivered);    
Was it helpful?

Solution

Its because

sm.sendTextMessage(stringnumber, null,finalmessage, sent, delivered);

it will send only the sms characters less than 160 only if you want to send sms with more than 160 characters then you need to use the method

sendMultipartTextMessage(String destinationAddress, String scAddress, ArrayList<String> parts, ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents)

check here for more details..SmsManager

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top