如何从android代码打开默认的邮件收件箱? [英] How to open the default mail inbox from android code?

查看:614
本文介绍了如何从android代码打开默认的邮件收件箱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将按钮链接到邮件应用程序.不是发送邮件,而是打开收件箱.

I'm trying to link a button to the mail app. Not to send mail, but just to open the inbox.

我应该用Intent intent = new Intent(...)这样做吗?

如果是,( )之间应该是什么?

If so, what should be between the ( )?

推荐答案

如果目标是打开默认电子邮件应用程序以查看收件箱,则关键是添加一个意图类别并使用ACTION_MAIN意图,如下所示:

If the goal is to open the default email app to view the inbox, then key is to add an intent category and use the ACTION_MAIN intent like so:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_APP_EMAIL);
getActivity().startActivity(intent);

https://developer.android.com/reference/android/content/Intent.html#CATEGORY_APP_EMAIL

这篇关于如何从android代码打开默认的邮件收件箱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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