如何在按钮单击的Android Studio上发送邮件?

时间:2019-01-09 17:28:22

标签: android android-studio email android-intent

我要发送电子邮件,当单击按钮时,我要基于电子邮件的应用程序列表。当我使用下面的源代码时,它将所有基于消息的应用程序输出为如图所示

second

当我点击按钮时,此类应用正在显示

pdf manual

  

但是我只想要基于电子邮件的应用程序,例如。 要获取此类应用列表,我应该进行哪些更改?

enter image description here

2 个答案:

答案 0 :(得分:2)

您可以使用此

geom_split_violin()

答案 1 :(得分:0)

只需在您的onClicklistener中调用电子邮件的意图,

Intent email = new Intent(Intent.ACTION_SEND);  
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});  
email.putExtra(Intent.EXTRA_SUBJECT, subject);  
email.putExtra(Intent.EXTRA_TEXT, message);  

//need this to prompt`enter code here`s email client only  
email.setType("message/rfc822");  

startActivity(Intent.createChooser(email, "Choose an Email client :"));