qwerty
qwerty

Reputation: 143

Send SMS to multiple recipients via Intent

I am trying to send SMS to multiple recipients viaINTENT. I tried the following to do it:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.putExtra("sms_body", etmessage.getText().toString());
intent.setData(Uri.parse("smsto:" + returnedItems));
intent.setType("vnd.android-dir/mms-sms");
mcontext.startActivity(intent);
                         

Where returnedItems is of Contact Numbers

But the problem is that my recipients numbers are not setting on TO section on SMS INTENT where TEXT is displayed on TEXT section.

Upvotes: 9

Views: 6953

Answers (4)

Abhiroop Nandi Ray
Abhiroop Nandi Ray

Reputation: 397

I have solved this by the following way.

Intent intent = new Intent(Intent.ACTION_SEND);
String numbers = "1234567890;9876543210;453678920"
intent.putExtra("address", numbers);
context.startActivity(Intent.createChooser(intent, context.getString(R.string.share_image)));

The numbers are separated by semi-colon (;). I read in some mobile phones the numbers need to separated by comma (,).

Hope this will help.

Upvotes: 0

Kishore Reddy
Kishore Reddy

Reputation: 2454

Intent smsIntent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:" + pointsList));
smsIntent.putExtra("sms_body", "Hi Friends & Families, My Location is feeling unsafe in this location");
startActivity(smsIntent);

pointsList is something like ArrayList, for example [8777675673,8566463454,7776666664]. It is working fine.

Upvotes: 0

Niranj Patel
Niranj Patel

Reputation: 33238

Did you tried below ?

Intent mIntent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:999999;888888"));

I also found out ";" is not working in Samsung device. You have to add "," instead of ";" for samsungs devices.

Intent mIntent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:999999,888888"));

Also check this answer

Upvotes: 5

Swayam
Swayam

Reputation: 16354

Make sure that the numbers are seperated by ; .

Intent smsIntent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:1234456;234567"));
smsIntent.putExtra("sms_body", etmessage.getText().toString());
startActivity(smsIntent);

always works for me!

Upvotes: 7

Related Questions