Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_EMAIL, "emailaddress@emailaddress.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "I'm email body.");
startActivity(Intent.createChooser(intent, "Send Email"));
The above code opens a dialog showing following apps:- Bluetooth, Google Docs, Yahoo Mail, Gmail, Orkut, Skype etc.
Actually, I want to filter these list-options. I want to show only email related apps e.g. Gmail, Yahoo Mail. How to do it?
I've seen such example on 'Android Market' application.
- Open Android Market app
- Open any application where developer has specified his/her email address. (If you can't find such app just open my app:- market://details?id=com.becomputer06.vehicle.diary.free , OR search by 'Vehicle Diary')
- Scroll down to 'DEVELOPER'
- Click on 'Send Email'
The dialog shows only email Apps e.g. Gmail, Yahoo Mail etc. It does not show Bluetooth, Orkut etc. What code produces such dialog?
I am updating Adil's answer in Kotlin,
There are three main approaches:
1. Custom
Uri
:2. Using
Intent
extras:3. Support Library
ShareCompat
:This works for me:
i.e. use the
ACTION_SENDTO
action rather than theACTION_SEND
action. I've tried it on a couple of Android 4.4 devices and it limits the chooser pop-up to only display email applications (Email, Gmail, Yahoo Mail etc) and it correctly inserts the email address and subject into the email.Works on All android Versions:
If you want to ensure that your intent is handled only by an email app (and not other text messaging or social apps), then use the
ACTION_SENDTO
action and include the "mailto:" data scheme. For example:I found this in https://developer.android.com/guide/components/intents-common.html#Email
Following Code worked for me!!