Reputation: 287
I would like to have a share action that will popup a chooser only with email options (email, gmail... according to installed apps) and also copy to clipboard. any snippet would be much appreciated.
EDIT: this is what I've tried so far:
Intent email_intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto","", null));
email_intent.putExtra(android.content.Intent.EXTRA_SUBJECT, entry.getDisplayName());
email_intent.putExtra(android.content.Intent.EXTRA_TEXT,"");
Intent clipboardIntent = new Intent();
clipboardIntent.setComponent(new ComponentName("com.google.android.apps.docs", "com.google.android.apps.docs.app.SendTextToClipboardActivity"));
clipboardIntent.setAction(Intent.ACTION_SEND);
clipboardIntent.setType("text/plain");
clipboardIntent.putExtra(Intent.EXTRA_TEXT, "text to copy to clipboard");
Intent chooserIntent = Intent.createChooser(email_intent, "Share entry");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { clipboardIntent });
startActivity(chooserIntent);
but it only shows me the email options. Iv'e also tried to use my own CopyToClipboardActivity but still same result
Upvotes: 1
Views: 750
Reputation: 8149
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "email body");
//emailIntent.putExtra(Intent.EXTRA_HTML_TEXT, body); //If you are using HTML in your body text
startActivity(Intent.createChooser(emailIntent, "Chooser Title"));
Upvotes: 2