From the course: Android Development: Understanding Intents

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Compose an email

Compose an email - Android Tutorial

From the course: Android Development: Understanding Intents

Start my 1-month free trial

Compose an email

- [Instructor] In this example, we're going to take what we learned earlier, when we saw how to send an SMS message, and apply to to a similar concept: sending email. The process is pretty similar. So here in AppsActivity.java I have some variables that contain information such as recipients, a subject, a message, some people on CC, and so on. So first I'm going to specify the action that we're going to use to send the email, and that is going to be standard Intent.ACTION_SENDTO. And similar to the SMS example, I'm going to use the setData function to create a URI for the mailto protocol, but instead of putting the addresses in the URI, I just need to add that to the intent. And again, this helps make sure that only email apps respond to this intent. So on my intent, I'm going to set the data, and the data is going to be a URI which I'm going to parse out of the mailto protocol. Alright. So once I have that URI built, I just need to add the data for the email to the intent. So let's…

Contents