【问题标题】:How can I start Android's email application (com.android.email)?如何启动 Android 的电子邮件应用程序 (com.android.email)?
【发布时间】:2012-05-01 16:10:17
【问题描述】:

如何启动 Android 的电子邮件应用程序 (com.android.email)?

【问题讨论】:

标签: android android-intent


【解决方案1】:

你可以从意图开始

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "your@email.com" });
intent.putExtra(Intent.EXTRA_SUBJECT, "YOUR SUBJECT");
intent.putExtra(Intent.EXTRA_TEXT, "YOUR MAIL BODY");
startActivity(Intent.createChooser(intent, ""));

【讨论】:

  • 我正在尝试打开“电子邮件”应用而不是某些电子邮件应用 =D
  • 我认为问题是询问如何打开应用程序(查看收件箱)
【解决方案2】:

由于您需要启动一个包,这应该是您正在寻找的解决方案:

Intent intent = getPackageManager().getLaunchIntentForPackage("com.android.email");
startActivity(intent);

【讨论】:

    【解决方案3】:

    我认为这对你打开电子邮件应用程序很有用。

    Intent mailClient = new Intent(Intent.ACTION_VIEW);
    mailClient.setClassName("com.google.android.gm", "com.google.android.gm.ConversationListActivity");
    mailClient.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(mailClient);
    

    【讨论】:

    • 我平板上的包不一样:mailClient.setClassName("com.sec.android.app.latin.launcher.email", "com.sec.android.app.latin.launcher.email.Launcher");
    【解决方案4】:

    使用以下意图在 android 设备上启动电子邮件应用程序:

    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    
    String[] recipients = new String[]{"a@email.com", "",};
    
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
    
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test");
    
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is email's message");
    
    emailIntent.setType("text/plain");
    
    startActivity(Intent.createChooser(emailIntent, "Send mail..."));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-04
      • 2010-11-24
      • 1970-01-01
      • 1970-01-01
      • 2011-02-11
      • 1970-01-01
      • 1970-01-01
      • 2012-01-04
      相关资源
      最近更新 更多