public static class NavDestination.Companion

Summary

Public methods

hasRoute

public static final boolean <T extends Object> hasRoute(@NonNull NavDestination receiver)

Checks if the NavDestination's route was generated from T

Returns true if equal, false otherwise.

Parameters
<T extends Object>

the route from KClass

Protected methods

parseClassFromName

protected static final @NonNull Class<C> <C extends Object> parseClassFromName(
    @NonNull Context context,
    @NonNull String name,
    @NonNull Class<C> expectedClassType
)

Parse the class associated with this destination from a raw name, generally extracted from the android:name attribute added to the destination's XML. This should be the class providing the visual representation of the destination that the user sees after navigating to this destination.

This method does name -> Class caching and should be strongly preferred over doing your own parsing if your Navigator supports the android:name attribute to give consistent behavior across all Navigators.

Parameters
@NonNull Context context

Context providing the package name for use with relative class names and the ClassLoader

@NonNull String name

Absolute or relative class name. Null names will be ignored.

@NonNull Class<C> expectedClassType

The expected class type

Throws
IllegalArgumentException

if the class is not found in the provided Context's ClassLoader or if the class is not of the expected type

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-01-30 UTC.