How to launch user's default mail client, default window(inbox)

╄→гoц情女王★ 提交于 2019-12-24 10:28:56

问题


Well I want to redirect user from app to default mail client in his phone. I heard that i can't just make intent that launch mailing app. So the general idea is to get possible applications for Intent.Action_Send, and just start one that user picked with Intent.CreateChooser(...);.

But it seems that i can't or i don't know how to get picked package name.


回答1:


In fact it is possible to launch the Mail client per Intent:

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.android.email/.activity.EmailActivity");
startActivity( LaunchIntent );

Hope this works for you.




回答2:


Try this:

        .....
        Intent emailIntent = new Intent(Intent.ACTION_SEND);
        emailIntent.setType("text/html");
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "some subject");
        .....
        startActivity(Intent.createChooser(emailIntent, "Email:"));
        .....

It swows Dialog with posible email clients. After user choose some, it redirect him to choosen client....




回答3:


So i made quick woraround for my problem. I'm letting user decide if to run gmail, on ConversationList, or open email client by himself. I also protected it from crashing when there will be no gmail client on some phone.



来源:https://stackoverflow.com/questions/9737934/how-to-launch-users-default-mail-client-default-windowinbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!