consulta sobre compartir imagen

191 views
Skip to first unread message

Jose Alberto Gonzalez von Schmeling

unread,
Dec 11, 2012, 2:09:42 PM12/11/12
to desarrollad...@googlegroups.com
Hola a todos:

Saque una fotografiá de la cámara y quisiera compartir dicha imagen.
Utilizo este código:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data){
        super.onActivityResult(requestCode, resultCode, data);
        Bitmap foto = (Bitmap)data.getExtras().get("data");
        imagen.setImageBitmap(foto);
       
       
        Uri uri = data.getData();
       
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("image/png");
        // uri looks like content://media/external/images/media/42
        intent.putExtra(Intent.EXTRA_STREAM, uri);
        startActivity(Intent.createChooser(intent , "Share"));
    }



Pero cuando quiero mandar a un mail con la imagen me sale un error. Al mandar texto en vez de la imagen, me manda el mail sin problema. No se que estoy haciendo mal. Si me podrían orientar o dar links sobre el tema.
Muchas gracias.
Saludos, jose


--
Podes encontrarme o comunicarte conmigo en:

Leonardo Fernandez

unread,
Dec 14, 2012, 7:00:14 AM12/14/12
to desarrollad...@googlegroups.com
es algo parecido y si te da tiempo lo puedes probar http://stackoverflow.com/questions/2729267/android-camera-intent

private Uri imageUri;

public void takePhoto(View view) {
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    File photo = new File(Environment.getExternalStorageDirectory(),  "Pic.jpg");
    intent.putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(photo));
    imageUri = Uri.fromFile(photo);
    startActivityForResult(intent, TAKE_PICTURE);
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case TAKE_PICTURE:
        if (resultCode == Activity.RESULT_OK) {
            Uri selectedImage = imageUri;
            getContentResolver().notifyChange(selectedImage, null);
            ImageView imageView = (ImageView) findViewById(R.id.ImageView);
            ContentResolver cr = getContentResolver();
            Bitmap bitmap;
            try {
                 bitmap = android.provider.MediaStore.Images.Media
                 .getBitmap(cr, selectedImage);

                imageView.setImageBitmap(bitmap);
                Toast.makeText(this, selectedImage.toString(),
                        Toast.LENGTH_LONG).show();
            } catch (Exception e) {
                Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT)
                        .show();
                Log.e("Camera", e.toString());
            }
        }
    }
}


--
Para participar es necesario que leas detenidamente las normas del grupo: http://goo.gl/AmNsS
---
Has recibido este mensaje porque estás suscrito al grupo "desarrolladores-android" de Grupos de Google.
Para publicar una entrada en este grupo, envía un correo electrónico a desarrollad...@googlegroups.com.
Para anular tu suscripción a este grupo, envía un correo electrónico a desarrolladores-a...@googlegroups.com
 
 

Jose Alberto Gonzalez von Schmeling

unread,
Dec 14, 2012, 3:24:39 PM12/14/12
to desarrollad...@googlegroups.com
me sirvió muchísimo. muchas gracias :)

2012/12/14 Leonardo Fernandez <leod...@gmail.com>
Reply all
Reply to author
Forward
0 new messages