Reputation: 1953
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
, ...)?
Upvotes: 1
Views: 2266
Reputation: 1953
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();
}
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.
Upvotes: 1