StaticKeyDeepLinkMatcher


A DeepLinkMatcher that matches based on a list of Filter and if all filters match, returns the input key in the MatchResult.

T The Type of the navigation key associated with this deep link matcher.

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)

Summary

Public constructors

<T : Any> StaticKeyDeepLinkMatcher(
    key: T,
    filters: List<DeepLinkMatcher.Filter>
)
Cmn

Protected functions

open DeepLinkMatcher.MatchResult<T>

Returns a MatchResult containing the key if all filters match the DeepLinkRequest.

Cmn

Public properties

T

the navigation key associated with this deep link matcher

Cmn

Public constructors

StaticKeyDeepLinkMatcher

<T : Any> StaticKeyDeepLinkMatcher(
    key: T,
    filters: List<DeepLinkMatcher.Filter>
)
Parameters
key: T

the navigation key associated with this deep link matcher

filters: List<DeepLinkMatcher.Filter>

the list of Filter to match with the DeepLinkRequest

Protected functions

matchRequest

protected open fun matchRequest(request: DeepLinkRequest): DeepLinkMatcher.MatchResult<T>

Returns a MatchResult containing the key if all filters match the DeepLinkRequest.

Public properties

key

val key: T

the navigation key associated with this deep link matcher