DeepLinkMatcher.Filter


A filter for a deep link, such as a mimeType.

Filters declared in a DeepLinkMatcher must be present in a DeepLinkRequest. On the other hand, a matching DeepLinkRequest may contain more filter info than is required by a DeepLinkMatcher

Summary

Public functions

Boolean

Matches a DeepLinkRequest to this Filter.

Cmn

Public functions

filterRequest

fun filterRequest(request: DeepLinkRequest): Boolean

Matches a DeepLinkRequest to this Filter.

Returns true if they are a match, false otherwise.

import androidx.navigation3.runtime.deeplink.DeepLinkMatcher
import androidx.navigation3.runtime.deeplink.DeepLinkRequest
import androidx.navigation3.runtime.deeplink.DeepLinkUri
import androidx.navigation3.runtime.deeplink.StaticKeyDeepLinkMatcher

// declare a matcher based on mime type
val mimeType = "image/jpg"
val mimeTypeFilter = DeepLinkMatcher.mimeTypeFilter(mimeType)
val matcher = StaticKeyDeepLinkMatcher(ImageKey, listOf(mimeTypeFilter))

// when handling a request
val request =
    DeepLinkRequest(
        uri = DeepLinkUri("$SAMPLE_BASE_PATH/images/"),
        extras = DeepLinkRequest.mimeTypeExtra(mimeType),
    )
// returns a valid result as long as mimeType matches
val matchResult: DeepLinkMatcher.MatchResult<ImageKey>? = matcher.match(request)