Android: Error al tomar una foto y enviarla por correo electrónico

I am trying to create an application to take a picture and then email it. I have spent the last few days messing around with my code and I have tried lots of different things and I still cant get it working. I can take a picture no problem its just when I go to send it my application crashes.Please see my code below:

public class Camera extends Activity implements View.OnClickListener {

ImageButton ib;
Button b;
ImageView iv;
Intent i;
final static int cameraData = 0;
Bitmap bmp;

protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    InputStream is = getResources().openRawResource(R.drawable.ic_launcher);
    bmp = BitmapFactory.decodeStream(is);

private void initialize() {
    ib = (ImageButton) findViewById(;
    b = (Button) findViewById(;
    iv = (ImageView) findViewById(;


public void onClick(View v) {

    // TODO Auto-generated method stub
    switch (v.getId()) {
        String emailaddress[] = { "", "", };

        Intent emailIntent = new Intent(Intent.ACTION_SEND);
        emailIntent.putExtra(Intent.EXTRA_EMAIL, emailaddress);

        // getPackageName() is your app package
        Uri path = Uri.parse("android.resource://" + getPackageName()
                + "/ + R.drawable.ic_launcher");
        emailIntent.putExtra(Intent.EXTRA_STREAM, path); // Replace your
                                                            // line
        startActivity(Intent.createChooser(emailIntent, "Send Mail"));

         * emailIntent.setType("image/jpeg");
         * emailIntent.putExtra(Intent.EXTRA_STREAM, bmp);
         * emailIntent.setType("message/rfc822");
         * startActivity(Intent.createChooser(emailIntent, "Send Mail"));

        i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(i, cameraData);


protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {

        Bundle extras = data.getExtras();
        bmp = (Bitmap) extras.get("data");
        bmp = BitmapFactory.decodeResource(getResources(),



When I go to send it I get the following error:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND (has extras)

Can someone please help me with this? Thanks

preguntado el 28 de agosto de 12 a las 10:08

It looks like you don't have any default app that supports email sending action. Did you check your phone for any such app? -

Yeah I have already designed an app just to send normal emails but when I try and add a picture it doesnt work -

You didn't take a picture. I think the issue is the attachment. Could you try this to initialize the Bitmap: bmb = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); -

I tried that and it still crashes when I select gmail to send the email! -

3 Respuestas

Intenta usar esto

startActivityForResult(((Intent.createChooser(emailIntent, "Send mail..."))), 0);

Respondido 28 ago 12, 10:08

I just tried that and and when I click send mail a dialog box pops up saying No applications can perform this action?? - DMC

Add emailIntent.setType("message/rfc822"); before using startActivity(emailIntent);. and use this also Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

Respondido 28 ago 12, 11:08

I tried that but Im still getting The application Gmail(process stopped unexpectedly. Please try again - DMC

Then it seems you didnt configure any email application like email or anything else. first make sure you have configured any mail account. - Raman

I have configured my email account.I just sent a test email there from my phone and it works perfectly - DMC

It looks like you don't have the appropriate app to handle this kind of intent. Try instead to create chooser, this will open a dialog with the application that can deal with such intent.

Try to add the next lines:

use the next link: getPackageName

//getPackageName() is your app package
    Uri path = Uri.parse("android.resource://"+ getPackageName() +"/ + R.drawable.ic_launcher");    
    emailIntent.putExtra(Intent.EXTRA_STREAM, path ); //Replace your line
            startActivity(Intent.createChooser(emailIntent, "Send Mail"));

Respondido 28 ago 12, 11:08

I tried this and this then gives me the option to select gmail but then it crashes once I select it! - DMC

The application Gmail(process stopped unexpectedly. Please try again - DMC

I just tried that there and its still crashing. Is it really that tricky to take a picture and send it with android?Am I approaching it the wrong way? - DMC

I think the problem is that you trying to send image that is in your drawable folder. Try to save your image in the internal memory of the device and then send it. pay attention, you still need to use a Content Provider to take that picture from your app to the email app. - Ofir A.

Tried that and still same error. I have updated my code above with your code. Did you mean to put uri instead of path at the end of emailIntent.putExtra? - DMC

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.