Send SMS through intent to multiple phone numbers

自闭症网瘾萝莉.ら 提交于 2019-12-30 09:57:05

问题


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?


回答1:


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();
            }


来源:https://stackoverflow.com/questions/18974898/send-sms-through-intent-to-multiple-phone-numbers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!