简体   繁体   中英

Send SMS through intent to multiple phone numbers

When i sending the sms through Intent an exception comes android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SENDTO typ=vnd.android-dir/mms-sms (has extras) }

See my code below:-

try {

                 Intent sendIntent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:5551212;5551212"));
                 sendIntent.putExtra("sms_body", sendSMSStringOnCustomCheckIn()); 
                 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();
            }

I want to send the SMS to 2 phone nembers and both the phone numbers should be display in the recipient box of default SMS box.How can i do that?

I got the solution of my Question. In SAMSUNG devices i have to separate the phone numbers with ',' while other devices are accept the ';' .So unfortunately have to do this ugly vendor specific decision within your source code.

 String separator = "; ";


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

Now my below code is working properly for SAMSUNG devices.

try {

                 Intent sendIntent = new Intent(Intent.ACTION_VIEW);
                 sendIntent.putExtra("address", "9971227563,9990900909");
                 sendIntent.putExtra("sms_body", sendSMSStringOnCustomCheckIn());
                 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();
            }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM