Reputation: 240
I am building an app that needs to send out a predefined text message on the click of a button (imagine a set of three buttons, each sending out a different line of text that has already been defined by the programmer).
I have no experience using the text features and I would like some guidance on how this could be done. Any help would be appreciated.
Thanks
Upvotes: 2
Views: 3747
Reputation: 1052
There are two possible ways to send SMS using Android :
SmsManager API
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("phoneNo", null, "your message goes here", null, null);
Built-in SMS application
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "default content");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
Of course, both need SEND_SMS permission.
<uses-permission android:name="android.permission.SEND_SMS" />
You can take reference of this tutorial : http://mobiforge.com/developing/story/sms-messaging-android
Hope this helps you.
Upvotes: 2
Reputation: 4187
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("phoneNo", null, "sms message", null, null);
and remember your permission
<uses-permission android:name="android.permission.SEND_SMS" />
Upvotes: 1