1

How can I get an event of gmail if email is sent or not in android. I've tried the below but could not achieve the result

Intent helpIntent = new Intent(Intent.ACTION_SEND);
            helpIntent.setData(Uri.parse("mailto:"));
            helpIntent.setType("message/rfc822");
            helpIntent.setPackage("com.google.android.gm");
            helpIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"xyz@gmail.com"});
            helpIntent.putExtra(Intent.EXTRA_SUBJECT, "Mail Subject");
            helpIntent.putExtra(Intent.EXTRA_TEXT, " TEXT BODY");
            startActivityForResult(helpIntent,1);


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 1)
    {
        if (resultCode == RESULT_OK)
        {
            Toast.makeText(this, "SENT", Toast.LENGTH_SHORT).show();
        }
        else
        {
            Toast.makeText(this, "DISCARD", Toast.LENGTH_SHORT).show();
        }
    }
}
Maitri
  • 513
  • 1
  • 3
  • 14
  • 1
    Duplicate https://stackoverflow.com/questions/32412432/how-to-get-callback-of-acion-send-intent – ADM Mar 27 '18 at 13:56
  • Apart from that this is not possible . Not with Implicit `Intent`. – ADM Mar 27 '18 at 13:58
  • Also, please remove `setPackage()` (not everybody *has* a Gmail account, let alone wants to use it). – CommonsWare Mar 27 '18 at 13:58
  • I don't see how this is a duplicate of that question. This calls for a response (startActivityForResult). That does not (startActivity). GMail (com.google.android.gm) does not return a response, where as Google Drive does. GMail will always return a false negative. – Philip Young Jun 07 '20 at 13:13

0 Answers0