Android:autoLink not working fully on my 4.4 device
Asked Answered
D

2

8

I'm new to Android programming, and I had this weird problem, I wanted to make phone numbers in a list clickable, where they send you the the dialer, now this worked on my Android phone, but it seems to only work on numbers of 10-chars, but when I tested it on a virtual device with 4.1.2, it worked well on all numbers in the list, I later tried a 4.4.2 virtual device, and I had the same problem there.

From what I could find on Google, I think the problem starts from Jelly Bean, so, is there a solution to this? I used this in the TextView element in the layout XML fileL android:autoLink="phone"

Demagoguery answered 3/2, 2014 at 21:30 Comment(0)
G
3

Was facing the same issue, for all the numbers longer than 10digits, solution is to just format them correctly and instead of 00 add a + sign infront of them, like: if number 00447172737475 , autolink wont work, but for +447172737475 it will work , hope it helps

Gitt answered 12/6, 2014 at 13:20 Comment(1)
Thank you, I kinda forgot to check back after all that time. Back then I worked it out by settling for 4.1.2, hopefully if that problem arises again I'll try your solution :) Thanks again.Demagoguery
B
3

In my case I wanted any numbers work as phone autolink, and for me worked only this:

private void setAutoLinkForPhoneWorkaround(TextView textView, final String phoneText) {
    textView.setText(phoneText);
    textView.setPaintFlags(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);
        }
    });
}
Ballot answered 2/12, 2016 at 16:12 Comment(1)
what is mBinding, its unknown variable in your example codeSelfregulating

© 2022 - 2024 — McMap. All rights reserved.