Attaching an drawable image to email in android

北城以北 提交于 2020-01-03 21:05:47

问题


I have a list of Drawable images in my application and want to send one of the images through 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 since i cannot get the image URI from the list of drawables. Can anyone help me how to send the image because if i use the above code i am getting an empty image of 0kb sent.


回答1:


You can do it by saving that image to a temporary location on internal/external cache directory as an image and then use that image's path in the attachment using Uri.



来源:https://stackoverflow.com/questions/9654576/attaching-an-drawable-image-to-email-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!