I am trying build a simple android app to send an email using android intent property.I used the onClicklistener of a button to trigger the intent function to call e-mail client but it is for some reason not working.All i see when i click the button is the Toast message from the bottom of the code.No prompt asking for e-mail clients or anything.
buttonSend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if ( mu.isInternetAvailable(SendMessage.this) ==true)
{
Log.i("START ONCLICK","");
String to = emailid.getText().toString();
String subject = textSubject.getText().toString();
String driverId1=driverid.getText().toString();
String message = textMessage.getText().toString();
SharedPreferences spmail = SendMessage.this.getSharedPreferences("email", MODE_WORLD_READABLE);
driver_mail=spmail.getString("email","");
Log.i("SEND MAIL id is","DRIVERID "+driver_mail);
Intent email = new Intent(Intent.ACTION_SENDTO);
//need this to prompts email client only
email.setType("message/rfc822");
email.setData(Uri.parse("mailto:"));
String[] to1={"info@ZapaTaxi.com"};
email.putExtra(Intent.EXTRA_EMAIL, to1);
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(email, "Choose an Email client :"));
Toast.makeText(SendMessage.this, "E-mail succesfully sent!!!!!", Toast.LENGTH_SHORT).show();
Intent it1=new Intent(SendMessage.this,Home.class);
startActivity(it1);
}
}
you have to place this code somewhere else:
Intent it1=new Intent(SendMessage.this,Home.class);
startActivity(it1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.