u936293
u936293

Reputation: 16244

Where to specify the phone number when using Intent.ACTION_SENDTO?

In here, the following example is given:

public void composeMmsMessage(String message, Uri attachment) {
  Intent intent = new Intent(Intent.ACTION_SENDTO);
  intent.setType(HTTP.PLAIN_TEXT_TYPE);
  intent.putExtra("sms_body", message);
  intent.putExtra(Intent.EXTRA_STREAM, attachment);
  if (intent.resolveActivity(getPackageManager()) != null) {
      startActivity(intent);
  }
}

Where is the destination number specified?

Upvotes: 1

Views: 182

Answers (2)

Sahil
Sahil

Reputation: 1419

Uri uri = Uri.parse("smsto:xxxxxxxxxx");
Intent intent = new Intent(Intent.ACTION_SENDTO, uri); 

Upvotes: 1

CommonsWare
CommonsWare

Reputation: 1006964

It isn't. That's a bug in that code. ACTION_SENDTO takes an smsto: or mailto: Uri:

Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:123456"));

where 123456 is the desired phone number.

Upvotes: 0

Related Questions