Android: How do I attach a temporary, generated image to an email?

前端 未结 3 1099
盖世英雄少女心
盖世英雄少女心 2020-11-29 02:50

I have a programmatically generated image that I want to send as an attachment via the ACTION_SEND and EXTRA_STREAM method.

But how do i do

3条回答
  •  一向
    一向 (楼主)
    2020-11-29 03:51

    I've just run into exactly the same issue (wanting to attach a text file in my case). If you look in the Android log, the reason for it is:

    02-28 21:01:28.434: E/Gmail(19673): file:// attachment paths must point to file:///mnt/sdcard. Ignoring attachment file:///data/data/com.stephendnicholas.gmailattach/cache/Test.txt
    

    As a workaround (as mentioned by HRJ), you can use a ContentProvider to provide access to files in your application's internal cache so that Gmail can attach them. I've just written up a blog post on how to do it.

    Hopefully that's of some help :)

提交回复
热议问题