Dialing a phone call on click of textview in android

Change it to :callIntent.setData(Uri.parse("tel:"+phone_no));

and i didnt add this: callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

but its working for me


this work for me :)

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:autoLink="phone" android:background="#ADD8E6" android:text="555-468-0602" />


Add this attribute to your textview component within the XML layout file like this:

<TextView 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:autoLink="phone"
    android:text="123 123 1234" />

 import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;

     public class CustomCellActivity extends Activity {
          

     /** Called when the activity is first created. */
                     

      @Override
          

     public void onCreate(Bundle savedInstanceState) {
                            

     super.onCreate(savedInstanceState);
        

     setContentView(R.layout.main);


           Button Phone = (Button) findViewById(R.id.button1);
           

     Phone.setOnClickListener(new View.OnClickListener() {
       @Override
      

     public void onClick(View v) {
   

     Intent sIntent = new Intent(Intent.ACTION_CALL, Uri
     

     .parse("tel:12345"));
   

     sIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   
    

     startActivity(sIntent);
  

    }
  

    });

This code works for me. try it urself.

Tags:

Android