Frage

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!

War es hilfreich?

Lösung 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);

Andere Tipps

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 );
        }
    });
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top