I want to show a Toast on sending the email successfully, I am sending an Email with the following code-
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {sToEmail});
emailIntent.putExtra(Intent.EXTRA_SUBJECT,emailHeader);
emailIntent.putExtra(Intent.EXTRA_TEXT,emailText);
emailIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivityForResult(Intent.createChooser(emailIntent, "Email"), REQUEST_CODE);
In onActivity result:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == REQUEST_CODE){
if(resultCode == RESULT_OK) {
Toast.makeText(getApplicationContext(), "Email Sent...",Toast.LENGTH_SHORT).show();
}
}
Problem is that I am getting result code 0 every time when I am sending, cancelling, discarding the mail. Result Code is not proper.
Please reply.