I tried to search on Google but didn't find an appropriate answer.
I want to click a TextView
and it will show a dialog that allows the user to choose optional email.
Any suggestion? Thanks in advance
I tried to search on Google but didn't find an appropriate answer.
I want to click a TextView
and it will show a dialog that allows the user to choose optional email.
Any suggestion? Thanks in advance
Try this:
Intent intet = new Intent(Intent.ACTION_SEND);
intet.setType("message/rfc822");
intet.putExtra(android.content.Intent.EXTRA_TEXT, body);
startActivity(intet);
This will open up a dialog that contains a list of apps installed on the device that can send an email.
Hope this helps. :)
A better option is to use the following, it will only open the applications that provide mail facility and not all apps that can share data.
Intent emailIntent = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("mailto:?subject=" + "subject" + "&body=" + "body" + "&to=" + email_id);
emailIntent.setData(data);
startActivity(emailIntent);
"subject"
is the subject of mail, "body"
is the content of the mail, and "email_id"
is the id of the receiver of the mail.
You can keep the subject , body and email_id empty if you want the user to fill in the spaces.
for open gmail app try this code:
Intent gmail = new Intent(Intent.ACTION_VIEW);
gmail.setClassName("com.google.android.gm","com.google.android.gm.ConversationListActivity");
startActivity(gmail);