Sending SMS Issues

Android provides two easy approaches to send SMS from your app. Before writing your code, include the permissions in manifest.xml.

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

1. Built-in API – SMS Manager

SmsManager smsManager = SmsManager.getDefault();
	smsManager.sendTextMessage("phoneNo", null, "sms message", null, null);

Default text message limits you to send only 160 characters.

ArrayList<String>parts = new ArrayList<String>();
parts = smsManager.divideMessage("sms message");
smsManager.sendMultipartTextMessage("phoneNo", null,parts, null, null);

To enter large text, use Multipart  text messages where you divide your message into parts and then send.

2. Using Intents

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
	sendIntent.putExtra("sms_body", "default content"); 
	sendIntent.setType("vnd.android-dir/mms-sms");
	startActivity(sendIntent);

Leave a comment