views:

290

answers:

1

I have an android app that wants to initiate an email. The following code works in an api level 5 emulator, but not on a level 2 emulator or device:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Email from MyApp");
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
   "This email was autogenerated by MyApp.");
try {
    startActivity(emailIntent);
} catch (Exception e) {
    Log.e(TAG,e.getMessage());
    showDialog(DIALOG_CANTSENDMAIL);
}

The exception thrown says:

No Activity found to handle Intent { action=android.intent.action.SEND (has extras) }

I can manually send email from all devices (emulated and real) tested, and this works in Level 5 api. The documentation on Intent.ACTION_SEND says it has been active since API level 1.

+2  A: 

I think the difference may be not so much in the API but in the apps available on the system. The Email app in particular was quite limited in Android 1.1 and 1.5, so I wouldn't be surprised if it wasn't able to handle ACTION_SEND.

Could also be that the same action works if you have the Gmail app configured, but not with the Email app only (like in the emulator).

Mirko Nasato