Java 电子邮件意图问题。无法选择电子邮件选项

Java 电子邮件意图问题。无法选择电子邮件选项,java,android,android-intent,Java,Android,Android Intent,更新: 设法对gmail的加载进行排序 现在我无法在加载意图时设置gmail的“To”、“subject”和“message”字段 显示我的电子邮件布局的屏幕截图: 显示已加载gmail意图的屏幕截图。但是没有根据传递的详细信息设置字段 代码: 如果默认电子邮件客户端没有帐户,则不应为Intent.ACTION\u SEND注册自己。确保您已将帐户添加到应用程序中,并尝试再次发送电子邮件。如上所述,使用“text/plain”作为类型 默认情况下不启用撰写活动,添加帐户后应立即启用撰写

更新:

设法对gmail的加载进行排序

现在我无法在加载意图时设置gmail的“To”、“subject”和“message”字段

显示我的电子邮件布局的屏幕截图:

显示已加载gmail意图的屏幕截图。但是没有根据传递的详细信息设置字段

代码:


如果默认电子邮件客户端没有帐户,则不应为
Intent.ACTION\u SEND注册自己。确保您已将帐户添加到应用程序中,并尝试再次发送电子邮件。如上所述,使用
“text/plain”
作为类型



默认情况下不启用撰写活动,添加帐户后应立即启用撰写活动。

您也可以在不使用外部应用程序的情况下发送电子邮件:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

String[] recipients = new String[]{"my@email.com", "",};

emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);

emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test");

emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is email's message");

emailIntent.setType("text/plain");

startActivity(Intent.createChooser(emailIntent, "Send mail..."));

finish();

设法把第二部分分类了。您需要将其作为字符串数组传递给Gmail,而不仅仅是作为纯字符串。希望这能在将来避免其他人的问题

使用intent.setType(“文本/普通”);谢谢你的回复。你的意思是我不需要选择电子邮件应用程序来发送电子邮件吗?我试过你的startActivity,我也遇到了同样的问题。我没有使用字符串数组。这个方法需要工作吗?我只是用我的edittext值设置我的“.EXTRA_EMAIL”。是的,你不需要应用程序来发送应用程序。您可以声明edittext并获取text
String s=et.getText().toString()。现在您可以
。。。额外文本(s)非常感谢您的回复。我已经添加了我的gmail帐户,现在当我点击send按钮时,onclick方法启动了intent。我现在唯一的问题是,我似乎无法用我传递的意图详细信息将Gmail设置为“主题”和“消息”字段?我将更新我的问题以显示这一点。
<activity
            android:name=".activity.MessageCompose"
            android:label="@string/compose_title"
            android:enabled="false"
            android:theme="@android:style/Theme.Holo.Light"
            >
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

String[] recipients = new String[]{"my@email.com", "",};

emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);

emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test");

emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is email's message");

emailIntent.setType("text/plain");

startActivity(Intent.createChooser(emailIntent, "Send mail..."));

finish();
try {
    final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{recipient});
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
    emailIntent.setType("plain/text");
    startActivity(Intent.createChooser(emailIntent, "Send email"));
} catch (ActivityNotFoundException e) {
    Log.i("app name", "Unable to send email");
}