Android的 - 如何直接打开电子邮件客户端 [英] Android - How to open the email client directly

查看:202
本文介绍了Android的 - 如何直接打开电子邮件客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打开,而不是显示选项的默认电子邮件客户端。我试过,但我没有得到,请谁能帮助我。

I want to open the default email client instead of showing the options. I tried but i am not getting please can anyone help me.

我用下面的code:

  final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

        emailIntent.setType("text/html");
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My Allergy Journal");       
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<small>"+sb.toString()+"</small>"));                                 
        startActivity(Intent.createChooser(emailIntent, "Email:"));   

这是显示的选项

但是我想直接打开,然后默认邮件客户端。

推荐答案

您可以用下面的code打开任何意图你想如Gmail中,脸谱,因为在我的$用在类型的电子邮件etc..Simple C $ C通过了Gmail的,如果你想打开Gmail时,通过变脸如果u想要打开Facebook的

You can used the following code to open whatever intent you want eg gmail, facebook, email etc..Simple in the type as used in my code pass "gmail" if you want to open gmail, pass "face" if u want to open facebook

Intent intent = new Intent(android.content.Intent.ACTION_SEND); 
intent.setType("text/html");
List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(intent, 0);

if (!resInfo.isEmpty())
{
    for (ResolveInfo info : resInfo) 
    {
    if (info.activityInfo.packageName.toLowerCase().contains(type) || info.activityInfo.name.toLowerCase().contains(type)) 
    {
            intent.putExtra(android.content.Intent.EXTRA_TEXT, htmlBody);
            intent.setPackage(info.activityInfo.packageName);   
            startActivity(Intent.createChooser(intent, getResources().getString(R.string.share_send_text)));
        }
} 

这篇关于Android的 - 如何直接打开电子邮件客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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