在我的应用程序中,我想向某人发送消息(电话联系),我希望用户决定他将使用哪个频道(短信,电子邮件......)。
文档建议在这种情况下使用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?
答案 0 :(得分:2)
ACTION_SENDTO似乎不支持您正在使用的联系人,也没有在文档中看到任何暗示(至少对我而言)的内容。然而,传递诸如sms:// 2065551212之类的URI对我来说非常有用。另请注意,ACTION_SENDTO不支持EXTRA_SUBJECT或EXTRA_TEXT。见ACTION_SENDTO for sending an email
谢谢, --randy