Android open emailclient programmatically

2019-01-25 06:32发布

Is it possible to open an emailclient such as gmail when I click a button in my app?

4条回答
贪生不怕死
2楼-- · 2019-01-25 07:30

If above code is not working then try this. Tested and working

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setType("vnd.android.cursor.item/email"); 
intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{Constants.FEEBBACK_EMAIL_ADDRESS});
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "SUBJECT");
startActivity(Intent.createChooser(intent, "Send mail using..."));
查看更多
你好瞎i
3楼-- · 2019-01-25 07:36
Intent i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
                    "mailto", EMAIL_ADDRESS, null));

up to date way of doing it

        i.putExtra(android.content.Intent.EXTRA_SUBJECT, SUBJECT);
        i.putExtra(android.content.Intent.EXTRA_TEXT, BODY);
        startActivity(Intent.createChooser(i, "Send email"));
查看更多
不美不萌又怎样
4楼-- · 2019-01-25 07:36

This Worked fine for me

Intent shareIntent = new Intent(Intent.ACTION_SEND);
                shareIntent.setType("text/plain");
                shareIntent.putExtra(Intent.EXTRA_EMAIL,new String[]{"mobiz@gmail.com"} );
                shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Feedback/Support: Speech to text App");
                startActivity(Intent.createChooser(shareIntent, "Share "));
查看更多
戒情不戒烟
5楼-- · 2019-01-25 07:38

Yes. You can launch it via Intents.

Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ emailAddress });
i.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
i.putExtra(android.content.Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(i, "Send email"));
查看更多
登录 后发表回答