Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 安卓系统中的意图类型动作。它是如何工作的?_Java_Android_Android Intent_Android Contacts - Fatal编程技术网

Java 安卓系统中的意图类型动作。它是如何工作的?

Java 安卓系统中的意图类型动作。它是如何工作的?,java,android,android-intent,android-contacts,Java,Android,Android Intent,Android Contacts,在我的应用程序中,我想发送一条消息给某人(电话中的联系人),我希望用户决定他将使用哪个渠道(短信、电子邮件等) 文件表明,在这种情况下应使用。我正在使用以下代码: private static void launchNewShareIntent(Context c, String subject, String text, String dialogTitle, Uri recipient) { Intent shareintent = new Intent(Intent.ACT

在我的应用程序中,我想发送一条消息给某人(电话中的联系人),我希望用户决定他将使用哪个渠道(短信、电子邮件等)

文件表明,在这种情况下应使用。我正在使用以下代码:

    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\u SENDTO?

ACTION\u SENDTO似乎不支持您正在使用的联系人,我也没有在文档中看到任何暗示这一点的内容(至少对我而言)。传递URI,例如sms://2065551212然而,这对我来说非常有效。另外,请注意,ACTION_SENDTO不支持额外的主题或额外的文本。看

谢谢,
--randy

你是在手机上还是在模拟器上进行测试?两者都有。两个人都给了我同样的信息,谢谢。看来我误解了这个意思。显然,“数据指定的某人”不是联系人id,而是电话号码或电子邮件地址。