Android开放邮件客户端

Spy*_*Zip 4 android android-intent

如何从我的应用程序打开邮件客户端,而不是发送电子邮件只是打开收件箱?我用的时候

Intent intent = new Intent(Intent.ACTION_VIEW);
        Uri data = Uri.parse("mailto:recipient@example.com?subject=" + "" + "&body=" + "");
        intent.setData(data);
        startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

它打开发送邮件视图,我想打开收件箱.

Spy*_*Zip 12

来自@CommonsWare的回答

这对我有用:

Intent intent=Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_EMAIL);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);//Min SDK 15
            startActivity(intent); 
Run Code Online (Sandbox Code Playgroud)

  • 对我来说,它只是打开 Gmail,但不允许我从已安装的电子邮件应用程序中进行选择。 (2认同)