how to Send the user to another activity after a email is send

Viewed 31

I am able to send the email successfully but I want to redirect the user to another activity after the email is send here is my try

private boolean sendEmail() {
    String foodLocation = location.getText().toString();
    String foodDescription = description.getText().toString();
    String emailAddress = "gsmulbah2500@gmail.com";
    String emailAddressList[] = {
        emailAddress
    };

    Intent intent = new Intent(Intent.ACTION_SEND);

    intent.putExtra(Intent.EXTRA_EMAIL, emailAddressList);
    intent.putExtra(Intent.EXTRA_SUBJECT, foodLocation);
    intent.putExtra(Intent.EXTRA_TEXT, foodDescription);

    if (ImageUri != null) {
        intent.putExtra(Intent.EXTRA_STREAM, ImageUri);
        intent.setType("image/*");
    } else {
        intent.setType("plain/text");
    }

    startActivityForResult(Intent.createChooser(intent, "Choice App to send email:"), 201);
    Intent i = new Intent(DonateFoodActivity.this, FinalActivity.class);


    return true;
}
1 Answers

add this function

public void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);


    if(requestCode == 201)
    {
        Intent i = new Intent(DonateFoodActivity.this,FinalActivity.class);
        startActivity(i);
    }
}
Related