Android open mail client

2020-03-24 05:16发布

问题:

How can I open mail client from my app, NOT SENDING EMAIL just open the inbox? when I use

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

It opens the send mail view, and I want to open the inbox.

回答1:

From @CommonsWare answer

This is what worked for me:

Intent intent=Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_EMAIL);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);//Min SDK 15
            startActivity(intent); 


回答2:

You can just use in your xml, like this:

android:autoLink="email"