2

I'd like to open the default SMS application and load the content with some text, but I don't want to provide a phone number. Instead, I'd like to leave that field in blank so that the user can choose the recipient.

This is how the SMS app is usually invoked:

Intent intent = new Intent(Intent.ACTION_SENDTO, "smsto:666");

However, I'd like to do as when opening email client:

Intent emailIntent = new Intent(Intent.ACTION_SEND);

Is it possible to do the same? If so, which attributes should I set to the intent so that it opens the SMS app?

Mister Smith
  • 27,417
  • 21
  • 110
  • 193

2 Answers2

5

Without appending phone number to URI also works:

    Uri uri = Uri.parse("smsto:");
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    intent.putExtra("sms_body", "Hello World!");  
    startActivity(intent);

I guess it works also with ACTION_VIEW action as described in https://stackoverflow.com/a/2372665/813951

Community
  • 1
  • 1
Mister Smith
  • 27,417
  • 21
  • 110
  • 193
1
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "hello world");  
sendIntent.setType("vnd.android-dir/mms-sms"); 
startActivity(sendIntent);
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156