In the documentation for ActivityResultContracts.OpenDocument, it says
The input is the mime types to filter by, e.g.
image/\*.
I can't find any additional explanation about the format of this mime type filter. The backslash seems to indicate that certain characters, such as asterisks, must be escaped. That seems very unusual for a mime type filter. Many examples can be found online, such as */*
(with no backslashes), or image/jpg
(with no asterisks).
Is the backslash in the above quote just a typo? Is there any documentation that tells specifically how mime type filters work in this context, and whether some characters might need to be backslash-escaped?
Is the backslash in the above quote just a typo?
Yes, or a copy-paste error from a regular expression. Either way, it should not be there.
Is there any documentation that tells specifically how mime type filters work in this context, and whether some characters might need to be backslash-escaped?
It is no different than how MIME types work with Intent
objects, because in the end, that contract puts that Array<String>
in an EXTRA_MIME_TYPES
Intent
extra.