I have both the phone number and address (including the zipcode) in the same TextView. I want the phone number to be clickable to call; however, this is making the zip code also clickable to make a phone call. How do I make it no longer clickable without creating another TextView? Thanks!
tvInfo.setText(Html.fromHtml("John Smith<br>123 Fake Street<br>Faketown, FK 12345<br><b>(804) 932-3300</b><br>"));
Linkify.addLinks(tvInfo, Linkify.PHONE_NUMBERS);
android will regard digits with count >=5 as phone numbers. so I think there will be at least 2 solutions:
1)a simple work around : if you are sure the length of phone numbers is more than 5, for example, at least 6 digits, you could make some work around:
this workaround is based on android source code of Linkify, in Linkify, the method:
will be called, while sPhoneNumberMatchFilter will filter the digits less than 5:
};
so we just replace the “PHONE_NUMBER_MINIMUM_DIGITS” with 6
2)a more complicated solution is, if your phone numbers are in a more specific format for example, must be something like “(xxx)xxx-xxxx”, you could use your own pattern to replace the Patterns.PHONE, to extract and apply links of phone numbers more accurately