强制android选择一个应用程序发送电子邮件 [英] Force android to pick an app for email sending
问题描述
我实施了从我的应用程序发送电子邮件。
I implemented sending emails from my application.
我使用了这个问题的这个问题作为指导实现这一点,请注意,在有人说使用 setType(message / rfc822);
因为它会滤除所有听到 ACTION_SEND
意图的其他电子邮件客户端。
I used this quesion on SO as a guide to achieve this, note that in the answers someone said to use setType("message/rfc822");
because it filters out all other email client that listen to the ACTION_SEND
intent.
我的问题是我的星系选项卡10.1仍然有两个应用程序听着意图,所以弹出窗口仍然打开询问我要使用的电子邮件客户端。 (gMail应用或默认的电子邮件应用)。我无法卸载一个,所以列表不会弹出,但我不想要。
My problem is that my galaxy tab 10.1 still has two application that listen to the intent, so a popup still opens asking me what email client I want to use. (The gMail app or the default eMail app). I can't uninstall one so the list won't popup, but I don't want to either.
有没有办法强制Android立即在列表中使用第一个?所以用户可以跳过弹出对话框?
Is there a way to force android to just use the first one in the list instantly? So the user can skip the popup dialog?
这是我现在的代码:
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.notes_from_pf));
i.putExtra(Intent.EXTRA_TEXT , context.getString(R.string.mail_message));
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(context, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
推荐答案
查询应用程序,获取列表注册发送动作并选择一个的应用程序,创建意图,设置类名称并启动您的意图,并完成
query applications, get a list of applications which are register to send action and choose one, create an intent, set class name and start your intent and you're done
这篇关于强制android选择一个应用程序发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!