Intent-Filter for content:// URI on Android 9 and higher

喜你入骨 提交于 2020-02-07 03:09:49

问题


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

Now, the same screen on Android 9+ delivers intent like this:

content://media/external/downloads/25

Is there a possibility to detect my file extension with such intent-uri format without writing an intent filter that just detects all intents (*)?

Any help would be appreciated!


回答1:


Is there a possibility to detect my file extension with such intent-uri format without writing an intent filter that just detects all intents (*)?

No, sorry.

On Android 8 (and before) there was a possibility to do this as intent url was delivered like this

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.

this comes from Chrome downloads screen

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.



来源:https://stackoverflow.com/questions/59454141/intent-filter-for-content-uri-on-android-9-and-higher

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!