UPDATE
官方做法:
public void composeEmail(String[] addresses, String subject) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_EMAIL, addresses);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
Ref link https://developer.android.com/guide/components/intents-common.html#Email
旧答案
接受的答案不适用于 4.1.2。这应该适用于所有平台:
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto","[email protected] /cdn-cgi/l/email-protection", null));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Body");
startActivity(Intent.createChooser(emailIntent, "Send email..."));
更新:根据marcwjj https://stackoverflow.com/users/1446995/marcwjj,似乎在 4.3 上,我们需要传递字符串数组而不是电子邮件地址的字符串才能使其工作。我们可能需要再添加一行:
intent.putExtra(Intent.EXTRA_EMAIL, addresses); // String[] addresses