djk djk - 1 year ago 104
Android Question

Send SMS in android

I want to send sms.

What is the intent for SMS sending...or any other code?
I want to show compose sms view with my pre-define text passing over in message field.

Is there any help for that?


this question pre-dates the "SmsManager" era on Android.

For 2014+ simply use SmsManager

Ads Ads
Answer Source

You can use the following code:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("sms:"
                        + phoneNumber)));

Make sure you set phoneNumber to the phone number that you want to send the message to

You can add a message to the SMS with (from comments):

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + phoneNumber));     
intent.putExtra("sms_body", message); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download