我需要从我的Android应用程序发送电子邮件。所以,我送2个参数(电子邮件和主题)的电子邮件客户端应用程序,但是当应用程序打开的电子邮件客户端,只有受加参数和电子邮件参数没有设置。
我该如何解决这个问题?
字符串getMail = email.toString(); Log.d(GET MAIL:getMail); 字符串主题=主题; 意图emailIntent =新意图(Intent.ACTION_SEND); emailIntent.putExtra(Intent.EXTRA_EMAIL,getMail); emailIntent.putExtra(Intent.EXTRA_SUBJECT,学科);//需要这个提示仅电子邮件客户端 emailIntent.setType(信息/ RFC822); startActivity(Intent.createChooser(emailIntent,选择电子邮件客户端));
解决方案
修改 emailIntent.putExtra(Intent.EXTRA_EMAIL,getMail);
到
emailIntent.putExtra(Intent.EXTRA_EMAIL,新的String [] {getMail});
I need to send an e-mail from my Android application. So, I send 2 parameters ( e-mail and subject) to the e-mail client app, but when app opens e-mail client, there is only subject parameter added, and email parameter is not set.
How I can fix this?
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:"));
解决方案
Change emailIntent.putExtra(Intent.EXTRA_EMAIL, getMail);
to:
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{getMail});