7

I am launching a mail activity by

//Sending mail

final int SENT_MAIL = 1;

startActivityForResult(Intent.createChooser(i, "Send mail"),SENT_MAIL);

and in

onActivityResult(int req, int res,Intent data)

i am trying to find the result of email sending, so as to confirm if my mail was sent or was discarded by the user. I am recieving null for Intent data

i.e data =null

parameter in onActivityResult(int req, int res, Intent data), res is always 0.

ie. res = 0;

Please let me know what can be done in this case?

Thanks in advance!

Community
  • 1
  • 1
Abhinava
  • 1,030
  • 9
  • 19

1 Answers1

2

You need to contact the developers of everything that could possibly ever respond to your Intent (which you do not show above) and ask them if they support startActivityForResult() for such an Intent. Odds are, few do, and you will have difficult tracking down all possible Android email clients, anyway. If they do not support startActivityForResult(), while you can still call that method, you will not get meaningful results in onActivityResult().

Hence, what you want is impractical, IMHO.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks for your reply.. but still is there any work around..?? i just wan't a callback from native app (in this case.. i assume gmail on android phone to be a native app) – Abhinava Aug 31 '10 at 10:46
  • @Abhinava: "but still is there any work around..??" No. The AOSP Email application does not use `setResult()` and so will not work with `startActivityForResult()`. The Gmail application is closed source. You are welcome to contribute patches to the open source Email application to add this functionality for that specific app. – CommonsWare Aug 31 '10 at 11:02
  • Just to be clear, are you saying that startActivityForResult cannot be used with an intent using Gmail such as this: `new Intent(Intent.ACTION_SEND).setType("message/rfc822")` because it will return RESULT_CANCELLED everytime regardless of success? I could have sworn that it worked for me earlier but now I only get RESULT_CANCELLED. – dylan murphy May 14 '12 at 01:25
  • 4
    @dylanmurphy: I am saying that unless the activity is *specifically written to support `startActivityForResult()`*, then you will get `RESULT_CANCELED` for all such requests. `ACTION_SEND`, as a general rule, is not designed to support `startActivityForResult()`, as the documentation for `ACTION_SEND` does not supply instructions for the "result" as it does for other things (e.g., `ACTION_PICK`). – CommonsWare May 14 '12 at 21:21