Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an email address clickable?

Tags:

android

I have some text in my application that says in case you need extra help, please email us and here is the email address, blah, blah.

But I want them to be able to click the email link and have their email client open. Is that possible? Or is that bad practice?

If it is reasonable practice, how can it be done?

like image 990
GeekedOut Avatar asked May 05 '12 18:05

GeekedOut


People also ask

How do I hyperlink an email address?

In the message, select the text or picture that you want to display as the link. On the Insert tab, click Link or Hyperlink. Under Link to, click E-mail Address. Either type the email address that you want in the E-mail address box, or select an email address in the Recently used e-mail addresses list.

How do you make a clickable address?

Select the text or picture that you want to display as a hyperlink. Press Ctrl+K. You can also right-click the text or picture and click Link on the shortcut menu. In the Insert Hyperlink box, type or paste your link in the Address box.


2 Answers

This is a very reasonable request and the Linkify class will turn every email address into an appropriate link for you. Simply add the autoLink attribute to your XML:

<TextView     ...     android:autoLink="email" /> 
like image 87
Sam Avatar answered Sep 29 '22 13:09

Sam


You can make your text clickable by using setOnClickListener on the text

textView.setOnClickListener(new View.OnClickListener()); 

You can open the email client by creating a new Intent with the ACTION_SEND. Settype, the email address and subject like this:

Intent emailintent = new Intent(android.content.Intent.ACTION_SEND); emailintent.setType("plain/text"); emailintent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] {"[email protected]" }); emailintent.putExtra(android.content.Intent.EXTRA_SUBJECT, ""); emailintent.putExtra(android.content.Intent.EXTRA_TEXT,""); startActivity(Intent.createChooser(emailintent, "Send mail...")); 
like image 41
Priebe Avatar answered Sep 29 '22 14:09

Priebe