Attaching selected image to email in android

I have a list of Drawable images in my application and would like to send one of the images via mail. my code looks like

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/*");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Picture");                       
sendIntent.putExtra(Intent.EXTRA_STREAM,
                    Uri.parse(lstPhotos.get(newPosition).getPhotoURL()));
myActivity.startActivity(Intent.createChooser(sendIntent, "Email:"));

      

But in the above code, I have a problem as I cannot get the image URI from the drawables list. Can anyone help me how to send the image, because if I use the above code, I get an empty image of the 0kb uploaded.

+3


source to share


1 answer


You can do this by storing this image to a temporary location in the internal / external cache directory as an image and then use that image path in your application using a Uri .



+1


source







All Articles