何时删除 Intent.SEND 中用于附加电子邮件的临时文件?
我们在 Android 设备上生成一个临时文件并将其附加到电子邮件中。我们使用自定义内容提供程序将该文件提供给电子邮件应用程序。问题在于,电子邮件应用程序会多次访问该文件,而不是一次,直到它最终发送电子邮件(例如,每次它写入草稿时,我们都会收到请求)。
这使得很难知道何时删除该临时文件。
有什么想法可以安全地知道我们的电子邮件何时送达,以便我们可以清洁设备而不留下垃圾? (定期删除似乎也不合适,因为手机可以将草稿文件夹中的电子邮件保存一段时间)
非常感谢您的帮助!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是啊,是啊,我知道已经一岁了。但我们也遇到过同样的事情。
我们所做的是使用 ContentProvider.openFile() 按需合成数据并将其直接流式传输到电子邮件应用程序,而不是将其写入临时文件。为此,您需要从 ContentProvider 的 query() 方法返回符合 OpenableColumns 的行;然后电子邮件应用程序将返回 openFile() 并且您返回一个 ParcelFileDescriptor。
不幸的是,这有点黑魔法,我们发现许多应用程序都出错了 --- DropBox 有点问题,现在(我注意到你的问题的原因)我们正在与三星专有的蓝牙前端作斗争结尾。我不知道为什么供应商不能放过东西......
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...