Reputation: 14571
I'm trying to launch the configured email client on android to send an attachment. Thing is, when I do it in the emulator, there is no email client configured to do any sending. I've also configured onActivityResult() to try and stop the train-wreck within the program but it doesn't seem to be getting control when things blow up. why?
this is my intent:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{""});
intent.putExtra(Intent.EXTRA_SUBJECT, CSV_MAIL_SUBJECT);
intent.putExtra(Intent.EXTRA_TEXT, CSV_MAIL_MSGBODY);
intent.putExtra(Intent.EXTRA_STREAM, createCSV.tempfile.toURI ());
try
{
startActivityForResult (intent, CSV_MAIL_RESULT_CODE);
}
catch (ActivityNotFoundException anf)
{
Log.d (TAG, "Activity not configured.");
//TODO: toast or something here..
}
Upvotes: 1
Views: 479
Reputation: 1006614
Thing is, when I do it in the emulator, there is no email client configured to do any sending
This should raise an ActivityNotFoundException
from your startActivityForResult()
call.
BTW, your MIME type is wrong. It should be text/plain
.
I've also configured onActivityResult() to try and stop the train-wreck within the program but it doesn't seem to be getting control when things blow up. why?
Because, if I'm right, startActivityForResult()
is failing, so you will never be called with onActivityResult()
.
Upvotes: 1