适用于content://Android 9及更高版本上的URI的Intent-Filter [英] Intent-Filter for content:// URI on Android 9 and higher

查看:234
本文介绍了适用于content://Android 9及更高版本上的URI的Intent-Filter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个意图过滤器,该过滤器将允许我的应用打开自定义文件例外的文件.在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上不需要httphttps 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆