Show compose SMS view in Android

djk picture djk · Feb 11, 2011 · Viewed 277k times · Source

I want to send a sms with Android.

What is the intent for SMS sending?

I want to show the compose sms view with my pre-define text passing over in message field.

Answer

Ads picture Ads · Feb 11, 2011

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); 
startActivity(intent);