I have an activity with a button that sends a pre-defined email. The button is working and the email is sent, but when completed it goes back to the previous activity. I want it to remain on the same activity.
Is there a modification that’s needed to my code or am I suppose to put the code in an activity designed just for sending emails?
ImageView btnTest = (ImageView)findViewById(R.id.imageButtontest);
btnTest.setClickable(true);
btnTest.setVisibility(View.VISIBLE);
btnTest.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String[] recipients = new String[]{"android@someemail.com"};
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "My email body text");
emailIntent.setType("text/plain");
Activityname.this.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
finish();
}
});
Thanks!
Take care,
Shannon
this line closes the activity, which redirects your app to previous activity. so removing this line , should help you solve the problem of staying in the same activity.