Question

What I want to do is make a phone number click-able I guess you can say.

On my app there is two phone numbers on two different tabs. I want the user to be able to press the phone number (either or) and it will call the number from their phone.

Can you please lead me in the right direction! Thank you!

Was it helpful?

Solution 2

I found the answer on this website

Android – Creating links using linkify | aviyehuda.com

TextView myPhone = (TextView) findViewById(R.id.textView2);
myPhone .setText("the number you want");
Linkify.addLinks(myPhone , Linkify.PHONE_NUMBERS);

OTHER TIPS

Here's some code that will do this for you:

    tvPhone = (TextView) findViewById(R.id.tvPhone);
    tvPhone.setOnClickListener(new OnClickListener()
    {
        @Override
        public void onClick(View v)
        {
            Intent callIntent = new Intent(Intent.ACTION_DIAL);
            callIntent.setData(Uri.parse("tel:+" + tvPhone.getText().toString().trim()));
            startActivity(callIntent );
        }
    });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top