How to edit the text inside TextView having autoLink attribute in Android Studio?

51 views Asked by At

I basically want that when the users click the "Call Us" textView it will take them to dialer with a phone number pre-written and not directly start a call. I tried it using android:autoLink="phone" but it turns out I have to set the number to be called as text of textView. Can I set text of textView as "Call Us" but it will open up the dialer with a specific number?

Kindly help.

1

There are 1 answers

0
Rudrik Patel On BEST ANSWER

You can have the onClick event of the textview in which execute the following code:

Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:0123456789"));
startActivity(intent); 

Make sure that your application has the following permission if you want to call directly without the dial pad in that case you can remove the tel: from the above code.

<uses-permission android:name="android.permission.CALL_PHONE" />