0

I have a text(has phone number) placed in TextView with 'autoLink=phone'. It works fine with English and is not working for Spanish language support. Linkify is also not helping. Need help in this. Thank you.

Vishwa
  • 41
  • 1
  • 5

2 Answers2

1

Actually autoLink for phone, works with the language. It checks whether the contact number is valid contact number of the country which supports that language. Try some number which uses Spanish language like Colombia, Costa, you will see the link working.

Aditi
  • 455
  • 4
  • 13
1

Try this solution:

private void setAutoLinkForPhoneWorkaround(TextView textView, final String phoneText) {
    textView.setText(phoneText);
    textView.setPaintFlags(mBinding.phoneText.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("tel:" + phoneText));
            startActivity(intent);
        }
    });
}
DeniSHow
  • 1,394
  • 1
  • 18
  • 30