通过Intent打开电子邮件客户端(但不发送消息) [英] Opening email client via Intent (but not to send a message)

查看:103
本文介绍了通过Intent打开电子邮件客户端(但不发送消息)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以以编程方式打开电子邮件客户端,而无需强制发送邮件?我只希望该应用程序允许用户打开其电子邮件客户端以进行电子邮件检查:)

Is there a way to programically open email client, without a need to forcing message send? I just want the app to let user open his email client for email checking purposes :)

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    startActivity(Intent.createChooser(intent, ""));

此代码有效,但会强制用户发送新消息.

This code works but it forces user to send a new message.

推荐答案

我认为您应该将Intent.ACTION_SEND替换为Intent.ACTION_VIEW
我确信这会起作用,因为这会提示支持MIME的应用程序列表键入"message/rfc822",这样它将在您的设备(而不是gmail应用)中包括您的默认电子邮件客户端.

该代码怎么样:

I think you should replace Intent.ACTION_SEND to Intent.ACTION_VIEW,
i am sure this will work as this will prompt with list of application which support MIME type "message/rfc822" so it will include your default email client in your device other than gmail app.

How about this code:

final Intent emailLauncher = new Intent(Intent.ACTION_VIEW);
emailLauncher.setType("message/rfc822");
try{
       startActivity(emailLauncher);
}catch(ActivityNotFoundException e){

}

这篇关于通过Intent打开电子邮件客户端(但不发送消息)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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