更新:
管理以对gmail的加载进行排序。
现在我无法设置' To',' subject'和'消息'加载意图时的gmail字段。
显示我的电子邮件布局的屏幕截图:
显示加载的gmail意图的屏幕截图。但是没有根据传递的细节设置字段。
代码:
@Override
public void onClick(View sendEmailClick) {
Intent sendEmailIntent = new Intent(Intent.ACTION_SEND);
sendEmailIntent.setType("plain/text");
sendEmailIntent.putExtra(Intent.EXTRA_EMAIL, emailAdd);
sendEmailIntent.putExtra(Intent.EXTRA_SUBJECT, emailSub);
sendEmailIntent.putExtra(Intent.EXTRA_TEXT, emailMess);
startActivity(Intent.createChooser(sendEmailIntent, "Send email"));
//startActivity(Intent.createChooser(sendEmailIntent, "Send email..."));
}
答案 0 :(得分:1)
如果默认电子邮件客户端没有帐户,则不应为Intent.ACTION_SEND
注册自己。确保您已将某个帐户添加到该应用并尝试再次发送您的电子邮件。如上所述,使用"text/plain"
作为类型。
From what I can find on short notice:
<activity
android:name=".activity.MessageCompose"
android:label="@string/compose_title"
android:enabled="false"
android:theme="@android:style/Theme.Holo.Light"
>
默认情况下未启用撰写活动,应在添加帐户后启用。
答案 1 :(得分:0)
您也可以在没有外部申请的情况下发送电子邮件:
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();
答案 2 :(得分:0)
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");
}
答案 3 :(得分:0)
管理以获得第二部分到此排序。您需要将其作为String数组传递给Gmail,而不仅仅是纯字符串。希望这将在未来拯救其他人的问题!