Android:文件扩展名 Intent 过滤器无法与 GMail/Downloads 应用程序一起正常工作
Android: File Extension Intent Filter does not work properly with GMail/Downloads app
我有一个允许用户备份数据并希望他们能够通过文件管理器、GMail 和下载系统应用程序单击备份文件的应用程序。
我在清单文件中定义了以下意图...
<intent-filter
android:label="Simple Backup File"
android:priority="999" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.OPENABLE" />
<data
android:scheme="http"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="https"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="ftp"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="ftps"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="content"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="file"
android:host="*"
android:pathPattern=".*\.sbu" />
</intent-filter>
如果我从文件管理器而不是从 GMail 或下载列表中单击 .sbu 文件,则以上操作有效。我确实读到我需要一个 mimeType 来使内容方案工作,但是当我将 mimeType 定义为 */*
或 application/octet-stream
时,该功能甚至在文件管理器中停止工作。
我做错了什么?第一次写入文件时需要设置什么吗?你会如何最好地处理我的情况。
我通过将内容与文件数据方案一起放入其自己的 intent-filter 组中来使其工作,两者都具有 application/octet-stream.
的 mime 类型
<intent-filter android:priority="999" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.OPENABLE" />
<data
android:scheme="http"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="https"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="ftp"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="ftps"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="file"
android:host="*"
android:pathPattern=".*\.sbu" />
</intent-filter>
<intent-filter android:priority="999" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.OPENABLE" />
<data
android:scheme="file"
android:mimeType="application/octet-stream"
android:pathPattern=".*\.sbu" />
<data
android:scheme="content"
android:mimeType="application/octet-stream"
android:pathPattern=".*\.sbu" />
</intent-filter>
我有一个允许用户备份数据并希望他们能够通过文件管理器、GMail 和下载系统应用程序单击备份文件的应用程序。
我在清单文件中定义了以下意图...
<intent-filter
android:label="Simple Backup File"
android:priority="999" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.OPENABLE" />
<data
android:scheme="http"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="https"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="ftp"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="ftps"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="content"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="file"
android:host="*"
android:pathPattern=".*\.sbu" />
</intent-filter>
如果我从文件管理器而不是从 GMail 或下载列表中单击 .sbu 文件,则以上操作有效。我确实读到我需要一个 mimeType 来使内容方案工作,但是当我将 mimeType 定义为 */*
或 application/octet-stream
时,该功能甚至在文件管理器中停止工作。
我做错了什么?第一次写入文件时需要设置什么吗?你会如何最好地处理我的情况。
我通过将内容与文件数据方案一起放入其自己的 intent-filter 组中来使其工作,两者都具有 application/octet-stream.
的 mime 类型 <intent-filter android:priority="999" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.OPENABLE" />
<data
android:scheme="http"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="https"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="ftp"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="ftps"
android:host="*"
android:pathPattern=".*\.sbu" />
<data
android:scheme="file"
android:host="*"
android:pathPattern=".*\.sbu" />
</intent-filter>
<intent-filter android:priority="999" >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.OPENABLE" />
<data
android:scheme="file"
android:mimeType="application/octet-stream"
android:pathPattern=".*\.sbu" />
<data
android:scheme="content"
android:mimeType="application/octet-stream"
android:pathPattern=".*\.sbu" />
</intent-filter>