I'm writing an Android app in Java which displays information relating to Spain, including phone numbers.
I am using Linkify to make these phone numbers linkable when they're displayed using this code
Linkify.addLinks(textViewPlaceNotesDetailView, Linkify.PHONE_NUMBERS);
This works fine.
My problem is that other numbers are also appearing as links, ie. years like 1965.
How can I prevent this? I only want phone numbers to be links.
NB. I thought of specifying a minimum length for the number, in this case 9 (Spanish phone numbers are 9 digit in the format 'xxx xxx xxx'). But I haven't been able to figure out how to do this.
Changing to using LinkifyCompat seems to have fixed this issue.
The code I'm now using is:
This works for both (Spanish) phone numbers and URLs.
I'm pretty certain this didn't resolve the issue when I first tried it but since then I have updated to use the latest dependencies and it is now working.
I don't know which library deals with this, but my dependencies now looks like this: