Wednesday, September 28, 2011

Launch CALL Activity on TextView or button Click in Android

First set the on click listener for your Button :

               btnMail.setOnClickListener(new View.OnClickListener() {
                       @Override
                       public void onClick(View arg0)
                                  {
                                     // TODO Auto-generated method stub
                                      call(txtPhone.getText().toString());
                                  }
                           });


Then Call this function !!!!

               private void call(String phone) {
                       try {
                              Intent callIntent = new Intent(Intent.ACTION_CALL);
                               callIntent.setData(Uri.parse("tel:"+phone));
                              startActivity(callIntent);
                             } catch (ActivityNotFoundException e) 

                       }
                   

And  Bingo thats IT!!!

No comments:

Post a Comment