Android:使用Intent发送电子邮件-仅提供电子邮件应用程序无效 [英] Android: Using Intent to send email - only offering email applications doesnt work
本文介绍了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
这篇关于Android:使用Intent发送电子邮件-仅提供电子邮件应用程序无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文