当我通过Intent发送短信时,出现异常 android.content.ActivityNotFoundException:找不到处理Intent的活动{act = android.intent.action.SENDTO typ = vnd.android-dir / mms-sms(有额外的)}
请参阅下面的代码: -
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个电话会员,这两个电话号码应该显示在默认短信箱的收件人框中。我该怎么做?
答案 0 :(得分:9)
我得到了我的问题的解决方案。在 SAMSUNG 设备中,我必须将电话号码与',分开,而其他设备则接受';&# 39; 。很遗憾,不得不在源代码中做出这个丑陋的供应商特定决定。
String separator = "; ";
if(android.os.Build.MANUFACTURER.equalsIgnoreCase("Samsung")){
separator = ", ";
}
现在我的以下代码适用于SAMSUNG设备。
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();
}