We generate a temporary file on an Android device and attach it to an email. We use a custom Content Provider to feed that file to the email application. The problem is that the email application access the file many times, instead of once, until it finally sends the email (for example, every time it writes a draft we get a request).
That makes hard to know when to delete that temporary file.
Any ideas on a safe method to know when our email was delivered so we can clean the device and not leave trash behind? (periodically delete also does not seem right as the phone can开发者_如何学运维 be for a while with the email in the Drafts folder)
Thanks a lot for the help!
Yeah, yeah, I know that this is a year old. But we've encountered the same thing.
What we did was to use ContentProvider.openFile() to synthesise the data on demand and stream it directly to the email app rather than write it to a temporary file. To do this you need to return a row conforming to OpenableColumns from your ContentProvider's query() method; the email app will then return openFile() and you return a ParcelFileDescriptor.
Unfortunately it's all a bit black magic and we've found that a number of apps get it wrong --- DropBox is a bit problematic, and right now (the reason I've noticed your question) we're fighting Samsung's proprietary Bluetooth front end. Why the vendors can't just leave things alone I don't know...
精彩评论