How to make an email address clickable?

前端 未结 5 794
-上瘾入骨i
-上瘾入骨i 2020-12-15 03:10

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 cl

5条回答
  •  轮回少年
    2020-12-15 03:35

    Please be aware of a little bug from API 24 onwards which makes the accepted solution not work if the local part of the email address has exactly 2 characters like "it@google.com".

    See the issue: https://issuetracker.google.com/issues/64435698

    Allegedly fixed already, but apparently not rolled out yet. (Don't you love it that they know about the issue and don't even bother to update the documentation accordingly? https://developer.android.com/reference/android/widget/TextView.html#attr_android:autoLink)

    So unless you're sure that you're not dealing with such 2-letter email addresses, you should rather use the accepted approach from here for the time being:

    TextView to send email when clicked

    Take care to remove the autolink attribute from the TextView then.

提交回复
热议问题