适用于content://Android 9及更高版本上的URI的Intent-Filter [英] Intent-Filter for content:// URI on Android 9 and higher
问题描述
我想编写一个意图过滤器,该过滤器将允许我的应用打开自定义文件例外的文件.在Android 8(及更低版本)上,有可能这样做,因为这样发送了意图网址(来自Chrome下载屏幕):
I want to write intent-filter that will allow my app to open files with custom files exception. On Android 8 (and before) there was a possibility to do this as intent url was delivered like this (this comes from Chrome downloads screen):
content://com.android.chrome.FileProvider/downloads/somefile.xyz
现在,Android 9+上的同一屏幕传达了这样的意图:
Now, the same screen on Android 9+ delivers intent like this:
content://media/external/downloads/25
是否有可能用这种intent-uri格式检测我的文件扩展名,而无需编写仅检测所有intent(*)的intent过滤器?
Is there a possibility to detect my file extension with such intent-uri format without writing an intent filter that just detects all intents (*)?
任何帮助将不胜感激!
推荐答案
是否有可能用这种intent-uri格式检测我的文件扩展名,而无需编写仅检测所有intent(*)的intent过滤器?
Is there a possibility to detect my file extension with such intent-uri format without writing an intent filter that just detects all intents (*)?
不,抱歉.
在Android 8(及更低版本)上,有可能这样做,因为这样发送了意图网址
On Android 8 (and before) there was a possibility to do this as intent url was delivered like this
在任何版本的Android上,都不需要content
Uri
包含文件扩展名,就像Web上不需要http
或https
URL包含文件扩展名一样.文件扩展名.
There is no requirement, on any version of Android, for a content
Uri
to contain a file extension, just as there is no requirement on the Web for an http
or https
URL to contain a file extension.
这来自Chrome下载屏幕
this comes from Chrome downloads screen
对于特定版本的Chrome可能是正确的.请不要以为Chrome浏览器将始终使用文件扩展名.而且,请不要假设每个Android设备用户都使用Chrome,并且仅 使用Chrome.无需其他应用程序使用带文件扩展名的content
Uri
.
That may be true for a particular version of Chrome. Please do not assume that Chrome will always use a file extension. And please do not assume that every Android device user uses Chrome and only uses Chrome. There is no requirement for other apps to use a content
Uri
with a file extension.
这篇关于适用于content://Android 9及更高版本上的URI的Intent-Filter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!