当用户单击某个电子邮件地址时,我想将电子邮件发送到特定的电子邮件地址,但是当我单击发送时,电子邮件字段为空白
String deviceInfo="Device Info:";
deviceInfo += "\n OS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")";
deviceInfo += "\n OS API Level: " + android.os.Build.VERSION.SDK_INT;
deviceInfo += "\n Device: " + android.os.Build.DEVICE;
deviceInfo += "\n Model (and Product): " + android.os.Build.MODEL + " ("+ android.os.Build.PRODUCT + ")";
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.putExtra(Intent.EXTRA_EMAIL, "[email protected]");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, deviceInfo);
if (emailIntent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivity(emailIntent);
}
使用以下方法:
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse(String.format("mailto:%s", "[email protected]")));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, deviceInfo);