email: Which are Intent.ACTION_SEND return values?

2019-02-27 07:43发布

问题:

When I launch

startActivity(new Intent(Intent.ACTION_SEND)) 

for sending an email, which are the returned values that I can test in the

onActivityResult(){...} 

?

Because (for example):

  • if the user exit the email client clicking su "Cancel", I want execute methodX(...)
  • otherwise i will execute methodY(...)

But to perform that, I need to know the Intent returned values. Is it possible?

回答1:

I don't think this is specified.

You can't be sure which Activity will end up handling your intent, and each Activity could return different resultCodes for the same logical outcome.

In my testing the text messaging app in the emulator returned zero no matter the outcome.



回答2:

I know it is a bit of a cludge but why not use the H-API (Human Application Programming Interface) to determine if it was sent. Pop up a dialog and ask them "Did you send the email?" or "Was the email sent OK?". Or add a required checkbox to the calling view "Email Sent?" and ensure it is checked before allowing the user to continue.

We try to "save" the user from having to interact as much as possible but I'm not convinced that is necessarily what they want. Not all solutions have to be solved with technical workarounds. Devs forget that sometimes.