Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android:autoLink not working fully on my 4.4 device

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"

like image 301
thinkereer Avatar asked Feb 03 '14 21:02

thinkereer


2 Answers

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

like image 183
baboo Avatar answered Nov 09 '22 12:11

baboo


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);
        }
    });
}
like image 37
DeniSHow Avatar answered Nov 09 '22 11:11

DeniSHow