我需要从我的Android应用程序发送电子邮件。因此,我将2个参数(电子邮件和主题)发送到电子邮件客户端应用程序,但是当应用程序打开电子邮件客户端时,只添加了主题参数,并且未设置电子邮件参数。
我如何解决这个问题?
String getMail = email.toString();
Log.d("GET MAIL:",getMail);
String subject = "Subject";
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, getMail);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
// need this to prompts email client only
emailIntent.setType("message/rfc822");
startActivity(Intent.createChooser(emailIntent,"Choose E-mail client:"));
答案 0 :(得分:3)
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"me@gmail.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From App");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
答案 1 :(得分:2)
更改emailIntent.putExtra(Intent.EXTRA_EMAIL, getMail);
为:
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{getMail});
答案 2 :(得分:2)
getMail应该是一个字符串数组......