如何在Android中注册我的应用以打开具有自定义文件类型的电子邮件附件? [英] How do I register my app in Android to open email attachments with a custom filetype?
问题描述
我的应用程序应该可以处理我的自定义.rmc
文件.我的用户将通过电子邮件接收它们,我希望我的应用程序能够打开它们,但最好打开我的应用程序无法处理的其他文件类型.
My app is supposed to handle my custom .rmc
files. My users are going to receive them via email and I want my app to be able to open them but ideally open as few other filetypes that my app can't handle as possible.
不幸的是,我在Android中使用以下Intent过滤器,但不幸的是,该过滤器无法在gmail中打开Attachemnts(gmail会显示一条错误消息,提示没有应用程序可以打开rmc
文件).
I use the following intent-filter in Android with unfortunately doesn't work for opening attachemnts in gmail (gmail gives an error message that there's no app to open rmc
files).
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="content" android:mimeType="*/*" android:host="*" android:pathPattern=".*\\.rmc"/>
<data android:mimeType="application/octet" />
<data android:mimeType="application/octet-stream" />
</intent-filter>
为了进行比较,以下过滤器捕获了文件,但是捕获的方式太多了:
For comparison the following filter catches the file but catches way too much:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/*" />
</intent-filter>
推荐答案
我的应用程序应该可以处理我的自定义.rmc文件.
My app is supposed to handle my custom .rmc files.
Android对文件扩展名的支持很少.
There is very little support for file extensions in Android.
不幸的是,我在Android中使用以下Intent过滤器,但不幸的是无法在gmail中打开Attachemnts
I use the following intent-filter in Android with unfortunately doesn't work for opening attachemnts in gmail
Gmail或任何其他应用程序不需要使用使用文件扩展名的content
Uri
值.因此,欢迎您使用<intent-filter>
,但不要假定它可以与所有电子邮件客户端或任何其他任意应用程序一起使用.
There is no requirement for Gmail, or any other app, to use content
Uri
values that use a file extension. So, you're welcome to have that <intent-filter>
, but do not assume that it will work with all email clients or any other arbitrary app.
如何在Android中注册我的应用程序以打开具有自定义文件类型的电子邮件附件?
How do I register my app in Android to open email attachments with a custom filetype?
你没有.
如果发送电子邮件的电子邮件客户端将为您的内容提供特定的特定MIME类型,请将该MIME类型用于android:mimeType
.例如,如果您要从某个服务器发送电子邮件,则应该能够控制附件的添加方式以及附件使用的MIME类型.
If the email clients sending the emails will supply a specific distinctive MIME type for your content, use that MIME type for android:mimeType
. For example, if you will be sending the emails from some server, you should be able to control how the attachment is added and what MIME type it uses.
否则,请为使用特殊MIME类型的此数据找到某种分发机制(例如,从Web服务器下载,在该服务器中配置服务器以使用该MIME类型提供文件).然后,对android:mimeType
使用该MIME类型.
Otherwise, find some distribution mechanism for this data that uses a distinctive MIME type (e.g., download from a Web server, where you configure the server to serve your files with that MIME type). Then, use that MIME type for android:mimeType
.
这篇关于如何在Android中注册我的应用以打开具有自定义文件类型的电子邮件附件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!