Android:使用Intent发送电子邮件-仅提供电子邮件应用程序无效
问题描述:
我正在尝试创建一个发送电子邮件的意图活动.使用
i am trying to create an intent activity that sends an email. Using
public void emailSend(View view){
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("plain/text");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Nächstes Treffen");
emailIntent.putExtra(Intent.EXTRA_EMAIL,adressListe);
if (emailIntent.resolveActivity(getPackageManager()) != null){
startActivity(emailIntent);
}
}
不仅为我提供了电子邮件应用,还为我提供了更多服务.使用
offers me more than just the email apps. Using
public void emailSend(View view){
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("plain/text");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Nächstes Treffen");
emailIntent.putExtra(Intent.EXTRA_EMAIL,adressListe);
if (emailIntent.resolveActivity(getPackageManager()) != null){
startActivity(emailIntent);
}
}
当我单击按钮时什么也没有发生.对于
Nothing happens when i click the button. For
emailIntent.setType("plain/text");
也尝试过
emailIntent.setType("messageage/rfc822");
和
emailIntent.setType("*/*");
所有结果都不尽相同,但没有一个仅会释放电子邮件应用程序.
all with varying results, but none only dislaying the email apps.
您知道如何解决此问题吗?帮助将不胜感激!
Do you have any idea how to solve this? Help would be greatly appreciated!
谢谢!
答
在使用下一种方法时,我仅看到电子邮件客户端:
I see only email clients when using the next approach:
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String [] {someaddress@gmail.com});
emailIntent.putExtra(Intent.EXTRA_SUBJECT,"Email subject"));
Intent chooser = Intent.createChooser(emailIntent, "Mail to ..");
if (emailIntent.resolveActivity(getPackageManager()) != null) {
startActivity(chooser);
}
else
//Do something if there's no Email client