在我的应用程序中,我想向某人(电话联系人)发送一条消息,我希望用户决定他将使用哪个 channel (短信、电子邮件...)。
文档表明 ACTION_SENDTO应在这种情况下使用。我正在使用以下代码:
private static void launchNewShareIntent(Context c, String subject, String text, String dialogTitle, Uri recipient) {
Intent shareintent = new Intent(Intent.ACTION_SENDTO);
shareintent.setData(recipient);
shareintent.putExtra(Intent.EXTRA_SUBJECT, subject);
shareintent.putExtra(Intent.EXTRA_TEXT, text);
shareintent.setType("text/plain");
shareintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
c.startActivity(Intent.createChooser(shareintent, dialogTitle));
}
例如,收件人所在的位置:content://com.android.contacts/contacts/755
但是,手机会显示一个对话框:“没有应用程序可以执行此操作。”
有人成功使用 ACTION_SENDTO 了吗?
最佳答案
ACTION_SENDTO 似乎不像您正在使用的那样支持联系人,我也没有在文档中看到任何暗示(至少对我来说)。但是,传递 URI(例如 sms://2065551212)对我来说效果很好。另请注意,ACTION_SENDTO 不支持 EXTRA_SUBJECT 或 EXTRA_TEXT。参见 ACTION_SENDTO for sending an email
谢谢, --兰迪
关于java - Android 中的 Intent 类型 ACTION_SENDTO。它是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6809641/