4

当我通过 Intent 发送短信时,出现异常android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SENDTO typ=vnd.android-dir/mms-sms (has extras) }

请参阅下面的代码:-

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

我想将短信发送到 2 个电话号码,两个电话号码都应显示在默认短信框的收件人框中。我该怎么做?

4

1 回答 1

10

我得到了我的问题的解决方案。在三星设备中,我必须用“,”分隔电话号码,而其他设备接受“;” .所以不幸的是必须在你的源代码中做这个丑陋的供应商特定的决定。

 String separator = "; ";


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

现在我下面的代码在三星设备上正常工作。

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();
            }
于 2013-09-24T07:40:29.873 回答