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..
}
This should raise an
ActivityNotFoundExceptionfrom yourstartActivityForResult()call.BTW, your MIME type is wrong. It should be
text/plain.Because, if I’m right,
startActivityForResult()is failing, so you will never be called withonActivityResult().