【发布时间】:2012-05-01 16:10:17
【问题描述】:
如何启动 Android 的电子邮件应用程序 (com.android.email)?
【问题讨论】:
-
这篇文章看起来像是stackoverflow.com/questions/2734749/…的副本
如何启动 Android 的电子邮件应用程序 (com.android.email)?
【问题讨论】:
你可以从意图开始
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, ""));
【讨论】:
由于您需要启动一个包,这应该是您正在寻找的解决方案:
Intent intent = getPackageManager().getLaunchIntentForPackage("com.android.email");
startActivity(intent);
【讨论】:
我认为这对你打开电子邮件应用程序很有用。
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");
使用以下意图在 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..."));
【讨论】: