Intent.EXTRA_EMAIL没有填充To字段

我试图使用意图从我的应用程序发送电子邮件,但电子邮件的收件人字段不会填充。 如果我添加代码来填写主题或文本,他们工作正常。 只是到字段不会填充。

我也尝试将types改为“text / plain”和“text / html”,但是我遇到了同样的问题。 任何人都可以帮忙吗?

public void Email(){ Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("message/rfc822"); //set the email recipient String recipient = getString(R.string.IntegralEmailAddress); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL , recipient); //let the user choose what email client to use startActivity(Intent.createChooser(emailIntent, "Send mail using...")); } 

我正在尝试使用的电子邮件客户端是Gmail

我认为你不是以array of string传递recipient

应该是这样的

 emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "someone@gmail.com" }); 

用这个

 public void Email(){ // use this to declare your 'recipient' string and get your email recipient from your string xml file Resources res = getResources(); String recipient = getString(R.string.IntegralEmailAddress); Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("message/rfc822"); //set the email recipient emailIntent.putExtra(Intent.EXTRA_EMAIL, recipient); //let the user choose what email client to use startActivity(Intent.createChooser(emailIntent, "Send mail using...")); ``} 

这将工作:)
这是Android文档有关Intent.Extra_Email的说法
– 所有“收件人”收件人电子邮件地址的string数组。
所以你应该喂正确的string你可以在这里阅读更多
http://developer.android.com/guide/components/intents-common.html#Email和这里http://developer.android.com/guide/topics/resources/string-resource.html或使用ACTION_SENDTO行动和包括“mailto:”数据scheme。; 例如:

 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); } 
 private void callSendMeMail() { Intent Email = new Intent(Intent.ACTION_SEND); Email.setType("text/email"); Email.putExtra(Intent.EXTRA_EMAIL, new String[] { "me@gmail.com" }); Email.putExtra(Intent.EXTRA_SUBJECT, "Feedback"); startActivity(Intent.createChooser(Email, "Send mail to Developer:")); }