开发者

Defining multiple mime-type and file extension (pathPattern) mappings in AndroidManifest.xml?

开发者 https://www.devze.com 2022-12-29 23:58 出处:网络
I\'m trying to define two different file extension mappings and two different mime-type IntentFilters in my manifest file but I can\'t seem to get them all to work; one works and others don\'t, etc.

I'm trying to define two different file extension mappings and two different mime-type IntentFilters in my manifest file but I can't seem to get them all to work; one works and others don't, etc.

How does one define multiple pathPatterns in开发者_开发知识库 the manifest? Should/can all mime-types and pathPatterns be defined in a single IntentFilter? Should they be different filters? I can't find any examples that show multiple, distinct mappings.


I have settled on grouping similar definitions together into distinct Intent Filters. For example, grouping the same pathPattern with different schemes (http, https, file) into one Intent Filter and defining another Intent Filter for a different pathPattern with the same set of schemes. I haven't encountered any specific guidelines or documentation about this so I've gone with my own aesthetic preference.

The source of my difficulties appears to have been the limited functionality of pathPattern. After seeing the .* explanation in the documentation, I had hoped pathPattern would accept other regex syntax but in practice it appears .* really is the only option for any kind of flexibility.

Also, the often cited method for defining a file-type filter has a bug/limitation that I have not been able to find a way around or an explanation for: pathPattern=".*\\.xyz" will work for "MyFile.xyz" but NOT for "My.File.xyz". I have since posted another question about this specific issue.

0

精彩评论

暂无评论...
验证码 换一张
取 消