Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I send sms to multiple phone numbers in android

Tags:

android

sms

using sms manager it does not work with a csv list; is there any way besides looping and sending more than one text to send to multiple recipients?

or is this by design a non-spam feature?

like image 479
nAndroid Avatar asked Oct 30 '10 03:10

nAndroid


2 Answers

Intent smsIntent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:5551212;5551212"));
smsIntent.putExtra("sms_body", "sms message goes here");
startActivity(smsIntent);

Add a semicolon delimited list of phone numbers to "smsto:" as the URI in the Intent constructor.

like image 140
pmko Avatar answered Oct 04 '22 21:10

pmko


In SAMSUNG devices You have to separate the phone numbers with ',' while other devices are accept the ';'.So your code should be like that:-

 String separator = "; ";
              if(android.os.Build.MANUFACTURER.equalsIgnoreCase("samsung")){
                separator = ", ";
              }
            try {

                 Intent sendIntent = new Intent(Intent.ACTION_VIEW);
                 sendIntent.putExtra("address", "55555"+seperator+"66666");
                 sendIntent.putExtra("sms_body", "Here is My text");
                 sendIntent.setType("vnd.android-dir/mms-sms");
                 startActivity(sendIntent);

            } catch (Exception e) {
                Toast.makeText(getApplicationContext(),
                    "SMS faild, please try again later!",
                    Toast.LENGTH_LONG).show();
                e.printStackTrace();
            }
like image 26
Deepak Sharma Avatar answered Oct 04 '22 21:10

Deepak Sharma