gpt4 book ai didi

android - 通过 Intent 向多个电话号码发送短信

转载 作者:太空宇宙 更新时间:2023-11-03 11:58:18 25 4
gpt4 key购买 nike

当我通过 Intent 发送短信时出现异常 android.content.ActivityNotFoundException: No Activity found to handle 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个电话号码,这两个电话号码都应该显示在默认短信框的收件人框中。我该怎么做?

最佳答案

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

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

关于android - 通过 Intent 向多个电话号码发送短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18974898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com