Android:接收电子邮件附件的意图
当涉及到细节时,我仍然没有完全弄清楚这个“意图”的事情。我想做的是在打开某个电子邮件附件时收到意图。附件将是一个文件,实际上是一个 SQLite 数据库,具有特定于我的应用程序的结构,并且具有也特定于我的应用程序的文件扩展名。
我在试验中注意到的是,当我从我的 PC(使用 Thunderbird)发送文件附件时,它使用 MIME 类型“application/octet-stream”进行编码。当我尝试在 Android 手机(使用 K-9 邮件)上打开它时,它告诉我没有“application/octet-stream”的应用程序。
那么我应该在我的应用程序中做什么才能被识别为这种特定类型附件的服务应用程序,特别是因为我认为尝试使用这种 MIME 类型打开任何内容并不是一个好主意。
I still haven't quite got this "Intent" thing down when it comes to the details. What I'd like to do is to receive an intent when a certain email attachment is opened. The attachment will be a file that is actually an SQLite database with a structure specific to my app, and with a file extension that is also specific to my app.
What I've noticed in experimenting with this is that, when I send the file attachment from my PC (using Thunderbird), it is coded with a MIME type of "application/octet-stream". When I try to open this on my Android phone (using K-9 mail), it tells me that there is no app for "application/octet-stream".
So what do I do in my app to be recognized as a servicing app for this particular type of attachment, especially since I expect it's not a good idea to try to open anything with this MIME type.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不知道。
以电子邮件附件的形式发明新文档在任何地方都不太有效。 Android 在这方面只是差了一个档次。
您实际上无法通过 MIME 类型设置
ACTION_VIEW
,因为您的 MIME 类型太笼统了。您无法通过文件扩展名设置ACTION_VIEW
,因为 AOSP 电子邮件应用程序处理的电子邮件附件上没有文件扩展名,并且可能其他电子邮件客户端也是如此。我鼓励您放弃将电子邮件附件作为文件的传递媒介,并找到一些其他可以拥有自定义 MIME 类型的解决方案(例如,从 Web 服务器下载文件,电子邮件中包含文件的链接)。然后,MIME 类型的
ACTION_VIEW
就可以正常工作。You don't.
Inventing new documents as email attachments doesn't work well pretty much anywhere. Android is just a notch worse in this regard.
You cannot realistically set up an
ACTION_VIEW
<intent-filter>
by MIME type, because your MIME type is too general. You cannot set up anACTION_VIEW
<intent-filter>
by file extension, because there is no file extension on email attachments as is processed by the AOSP email app, and perhaps other email clients as well.I encourage you to abandon email attachments as a delivery vector for your files, and find some other solution where you can have a customized MIME type (e.g., download the files from a Web server, with the emails containing a link to the files). Then, an
ACTION_VIEW
<intent-filter>
by MIME type can work OK.