praveenb
praveenb

Reputation: 10659

How to display phone call window when click on phone number text

Im displaying contact details on a screen. I need to display phone call window to appear when user clicks on phone number in the contact details.

Please let me know How i can do this

Thanks in advance

Upvotes: 8

Views: 2463

Answers (2)

Imran
Imran

Reputation: 11

use this code

String number = "9423012345";

txt.setTag(number);

txt.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {   

Intent callIntent = new Intent(Intent.ACTION_CALL);

callIntent.setData(Uri.parse("tel:"+(String) v.getTag()));

callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 

startActivity(callIntent);

}});    

And add this line to your manifest file

uses-permission android:name="android.permission.CALL_PHONE"

Upvotes: 1

praveenb
praveenb

Reputation: 10659

I find answer

<TextView  android:text="888-468-0602"  
    android:autoLink="phone" />

Upvotes: 16

Related Questions