从Android应用程序发送电子邮件 [英] Sending email from android app

查看:370
本文介绍了从Android应用程序发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为用户,用户可以通过发送电子邮件分享一些数据提供功能。 我用低于code。

I need to provide feature for users where users can share some data by sending email. I used below code.

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "testing email send.");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<b>this is html text in email body.</b>"));
startActivity(Intent.createChooser(emailIntent, "Email to Friend"));

这显示邮件应用,Gmail和蓝牙供用户选择。 我不希望用户显示蓝牙在此列表中。我需要做什么? 我有Facebook的应用程序,它不一样的东西,但不显示蓝牙在列表中。 我需要做的是一样的。

This shows mail app, gmail and bluetooth for user to choose. I dont want user to show bluetooth in this list. What i need to do ? I have facebook app, which does same thing, but doesn't show bluetooth in the list. I need to do the same.

推荐答案

您可以使用ACTION_SEND的ACTION_SENTTO,而不是得到的电子邮件客户端列表中。我想这对HTC野火其中有默认的电子邮件客户端,Gmail应用程序和k9-3.508释放安装。当我跑你code与ACTION_SENDTO,我得到了名单上面提到的3电子邮件客户端,而不是蓝牙不管蓝牙启用或禁用。我试了一下,当两个蓝牙启用,当蓝牙被禁用。它的工作很适合我。

You can use the ACTION_SENTTO instead of ACTION_SEND to get the list of e-mail clients. I tried this on HTC Wildfire which had default e-mail client, GMail app and k9-3.508-release installed. When I ran your code with ACTION_SENDTO, I got list of above mentions 3 e-mail clients and not bluetooth no matter if bluetooth was enabled or disabled. I tried it both when the bluetooth was enabled and when bluetooth was disabled. It worked well for me.

Intent emailIntent = new Intent(android.content.Intent.ACTION_SENDTO);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "testing email send.");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<b>this is html text in email body.</b>"));
startActivity(Intent.createChooser(emailIntent, "Email to Friend"));

这篇关于从Android应用程序发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆