2

I am developing an app with email sharing. The code I am using to launch the intent is standard Android ie:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);
emailIntent.setType("application/octet-stream");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hello");

context.startActivity(emailIntent);

The thing is, this launches the Gmail app in a fullscreen which I don't want. Can I make it a dialog similar to how iOS does below? If not, has it been written already, or do I need to write it myself.

enter image description here

Thanks

Joss Stuart
  • 1,856
  • 1
  • 17
  • 19

3 Answers3

2

You could create a Dialog with this layout to get the data from the user and send the actual email using the avaMail API as shown in the post

Sending Email in Android using JavaMail API without using the default/built-in app

Community
  • 1
  • 1
rgrocha
  • 1,461
  • 10
  • 19
1

You can't with ACTION_SEND. By sending this Intent, you're telling the system to start Gmail itself. You can pass "extras" in the Intent that fill in some of the useful data. This is a feature, in that you're allowing users to choose among apps that can handle ACTION_SEND, rather than forcing them to use Gmail.

If you want a dialog, you have to write it yourself first, then pass the values you collect to the email program the user chooses.

Joe Malin
  • 8,621
  • 1
  • 23
  • 18
  • This is what I suspected, thanks for confirming. In this case, how would you then pass the data from the custom intent to the email client. Would you not need to use ACTION_SEND again, resulting in the same circle? – Joss Stuart Oct 23 '12 at 08:45
0

By firing out Intent you are starting another application. No mailer (afair) supports any sort of embedding, so you need to write pictured activity itself and then, once user ends typing grab what's there and do ACTION_SEND. Yet, I recommend NOT doing so unless your users start complaining (which I think will not happen).

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141