MimeTypeFilter
class MimeTypeFilter
kotlin.Any | |
↳ | androidx.core.content.MimeTypeFilter |
Provides utility methods for matching MIME type filters used in ContentProvider.
Wildcards are allowed only instead of the entire type or subtype with a tree prefix. Eg. image\/*, *\/* is a valid filter and will match image/jpeg, but image/j* is invalid and it will not match image/jpeg. Suffixes and parameters are not supported, and they are treated as part of the subtype during matching. Neither type nor subtype can be empty.
Note: MIME type matching in the Android framework is case-sensitive, unlike the formal RFC definitions. As a result, you should always write these elements with lower case letters, or use android.content.Intent#normalizeMimeType
to ensure that they are converted to lower case.
MIME types can be null or ill-formatted. In such case they won't match anything.
MIME type filters must be correctly formatted, or an exception will be thrown.
Summary
Public methods | |
---|---|
static Boolean |
Matches one nullable MIME type against one MIME type filter. |
static String? |
Matches one nullable MIME type against an array of MIME type filters. |
static String? |
Matches multiple MIME types against an array of MIME type filters. |
static Array<String!> |
matchesMany(@Nullable mimeTypes: Array<String!>?, @NonNull filter: String) Matches multiple MIME types against an array of MIME type filters. |
Public methods
matches
static fun matches(
@Nullable mimeType: String?,
@NonNull filter: String
): Boolean
Matches one nullable MIME type against one MIME type filter.
Return | |
---|---|
Boolean |
True if the mimeType matches the filter . |
matches
@Nullable static fun matches(
@Nullable mimeType: String?,
@NonNull filters: Array<String!>
): String?
Matches one nullable MIME type against an array of MIME type filters.
Return | |
---|---|
String? |
The first matching filter, or null if nothing matches. |
matches
@Nullable static fun matches(
@Nullable mimeTypes: Array<String!>?,
@NonNull filter: String
): String?
Matches multiple MIME types against an array of MIME type filters.
Return | |
---|---|
String? |
The first matching MIME type, or null if nothing matches. |