Tuesday, September 27, 2011

Launch Mail 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
                                       mail(txtEmail.getText().toString());
                                  }
                           });


Then Call this function !!!!

             private void mail(String email)
                       {
                             Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                             emailIntent.setType("text/plain");
                             emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,email);
                             startActivity(emailIntent);
                       }

And  Bingo thats IT!!!

No comments:

Post a Comment