发送电​​子邮件意向意向、邮件

2023-09-11 11:25:51 作者:Pumpkin

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_EMAIL, "emailaddress@emailaddress.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "I'm email body.");

startActivity(Intent.createChooser(intent, "Send Email"));

以上code打开一个对话框,显示以下应用程序: - 蓝牙,谷歌文档,雅虎邮件,Gmail的,Orkut的,Skype公司等

The above code opens a dialog showing following apps:- Bluetooth, Google Docs, Yahoo Mail, Gmail, Orkut, Skype etc.

其实,我要过滤这些列表的选项。我想只显示邮件相关的应用程序如Gmail,雅虎邮件。怎么办呢?

Actually, I want to filter these list-options. I want to show only email related apps e.g. Gmail, Yahoo Mail. How to do it?

我见过这样的例子在安卓市场的应用程序。

I've seen such example on 'Android Market' application.

开启Android Market的应用程序 打开,其中开发人员指定他/她的电子邮件地址的任何应用程序。 (如果你不能找到这样的应用程序只需要打开我的应用程序: - 市场://细节ID = com.becomputer06.vehicle.diary.free,或按汽车日记搜索) 向下滚动到开发 点击发送电子邮件

该对话框只显示邮件应用程序如Gmail,雅虎邮件等,它不显示蓝牙,Orkut的等什么code产生这样的对话框?

The dialog shows only email Apps e.g. Gmail, Yahoo Mail etc. It does not show Bluetooth, Orkut etc. What code produces such dialog?

请提供一个答案,这样我就可以增加我的接受率。 ;)

Please provide an answer, so I can increase my 'accept rate'. ;)

推荐答案

时,你会改变你的intent.setType像下面你会得到

when you will change your intent.setType like below you will get

intent.setType("text/plain");

使用 android.content.Intent.ACTION_SENDTO(新意图(Intent.ACTION_SENDTO); ),以获取电子邮件客户端只有列表中,没有Facebook或其他应用程序。就在电子邮件客户端。

Use android.content.Intent.ACTION_SENDTO (new Intent(Intent.ACTION_SENDTO);) to get only the list of e-mail clients, with no facebook or other apps. Just the email clients.

我不建议你直接到电子邮件应用程序。让用户选择他喜欢的电子邮件应用程序。不要限制他。

I wouldn't suggest you get directly to the email app. Let the user choose his favorite email app. Don't constrain him.

如果您使用ACTION_SENDTO,putExtra不起作用添加主题和文本的意图。使用URI来添加主题和正文文本。

If you use ACTION_SENDTO, putExtra does not work to add subject and text to the intent. Use Uri to add the subject and body text.

编辑: 我们可以使用消息/ RFC822 而不是text / plain的的MIME类型。然而,这并不表示只提供电子邮件客户端 - 表示提供支持的消息/ RFC822数据什么。这可以很容易地包括一些应用程序,没有电子邮件客户端。

We can use message/rfc822 instead of "text/plain" as the MIME type. However, that is not indicating "only offer email clients" -- it indicates "offer anything that supports message/rfc822 data". That could readily include some application that are not email clients.

消息/ RFC822 支持 .mhtml,.MHT,.mime

 
精彩推荐