Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android open emailclient programmatically

Is it possible to open an emailclient such as gmail when I click a button in my app?

like image 599
Hannelore Avatar asked Apr 08 '11 15:04

Hannelore


People also ask

How do you open email app on Android?

Step 1: On the home screen, tap on Apps > Settings > Accounts or simply go to Apps > Email to open up the email app. Step 2: Tap on 'Add account' and select the kind of account you want to add, e.g. Email, Google, Personal (IMAP) or Personal (POP3).

How to open Intent in Android?

1.2. To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent. # Start the activity connect to the # specified class Intent i = new Intent(this, ActivityTwo.

What is Android Intent action VIEW?

An intent allows you to start an activity in another app by describing a simple action you'd like to perform (such as "view a map" or "take a picture") in an Intent object.


2 Answers

Yes. You can launch it via Intents.

Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ emailAddress });
i.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
i.putExtra(android.content.Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(i, "Send email"));
like image 164
Robby Pond Avatar answered Sep 28 '22 19:09

Robby Pond


Intent i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
                    "mailto", EMAIL_ADDRESS, null));

up to date way of doing it

        i.putExtra(android.content.Intent.EXTRA_SUBJECT, SUBJECT);
        i.putExtra(android.content.Intent.EXTRA_TEXT, BODY);
        startActivity(Intent.createChooser(i, "Send email"));
like image 31
Jonathan Avatar answered Sep 28 '22 17:09

Jonathan