smsManager.sendTextMessage not working for message that exceeds one sms character limit
android, android-studio, sms, smsmanager
Solution
This code might help you:
try {
SmsManager smsManager = SmsManager.getDefault();
ArrayList<String> msgArray = smsManager.divideMessage(msg);
smsManager.sendMultipartTextMessage(phoneNo, null,msgArray, null, null);
Toast.makeText(getApplicationContext(), "Message Sent",Toast.LENGTH_LONG).show();
} catch (Exception ex) {
Toast.makeText(getApplicationContext(), ex.getMessage().toString(), Toast.LENGTH_LONG).show();
ex.printStackTrace();
}
Problem
I am working with a project which sends firebase dynamic link invitation to friends via sms. My code runs perfecly fine and sends sms when I send smaller links as invitation. like ``` try { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(number, null, "Check It Out. This one is very nice and useful https://v5uht.app.goo.gl/Zi7X", null, null); Toast.makeText(getApplicationContext(), "Cheers :D :D", Toast.LENGTH_LONG).show(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "SMS faild, please try again.", Toast.LENGTH_LONG).show(); e.printStackTrace(); } ``` But it doesn't send sms when I include bigger link which exceeds one sms character limit though it shows the toast notification. ``` String myNewLink = "https://v5uht.app.goo.gl/?link=http://expensecount.com/&apn=com.chtl.ribath.fdynamic1&amv=1&afl=https://play.google.com/store/apps/details?id%3Dcom.belief.colorgalaxy&myPage=2"; try { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(number, null, myNewLink, null, null); Toast.makeText(getApplicationContext(), "Cheers :D :D", Toast.LENGTH_LONG).show(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "SMS faild, please try again.", Toast.LENGTH_LONG).show(); e.printStackTrace(); } ``` what shall I do to include the whole link which is in myNewLink and make it working. Thank you.