明确意图Android的默认电子邮件客户端 [英] Explicit intent for Android default email client

查看:158
本文介绍了明确意图Android的默认电子邮件客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要直接启动默认的Andr​​oid电子邮件客户端的撰写活动。我还需要多个附件添加到电子邮件。哪里可以找到用于创建一个明确意图的组件名称?什么是用于支持在默认的电子邮件客户端多个附件( Intent.ACTION_SEND Intent.ACTION_SENDTO , Intent.ACTION_SEND_MULTIPLE ,...)?

I need to directly start the compose activity of the default Android email client. I also need to add more than one attachment to the email. Where I can find the component name to use to create an explicit intent? What is the correct action name to use to support multiple attachments in the default email client (Intent.ACTION_SEND, Intent.ACTION_SENDTO, Intent.ACTION_SEND_MULTIPLE, ...)?

推荐答案

好吧,检查了Android系统的电子邮件应用程序的源$ C ​​$ C我终于找到了。

Ok, checking the source code of the Android Email system app I finally found it.

String subject = ...
String text = ...
ArrayList<Uri> attachments = ...
Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, text);
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);
intent.setClassName("com.android.email", "com.android.email.activity.MessageCompose");
try {
    startActivity(intent);
} catch (ActivityNotFoundException anfe) {
    anfe.printStackTrace();
}

这似乎是工作在Android 4.0到Android 4.3。在Android 4.4系统(奇巧)活动的名称 com.android.email.activity.ComposeActivityEmail 变了,但我还没有测试它。

This seems to work from Android 4.0 to Android 4.3. In Android 4.4 (KitKat) the name of the activity has changed in com.android.email.activity.ComposeActivityEmail, but I haven't tested it.

这篇关于明确意图Android的默认电子邮件客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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