Known indirect subclasses

NavType denotes the type that can be used in a NavArgument.

There are built-in NavTypes for primitive types, such as int, long, boolean, float, and strings, parcelable, and serializable classes (including Enums), as well as arrays of each supported type.

You should only use one of the static NavType instances and subclasses defined in this class.

Parameters
<T : Any?>

the type of the data that is supported by this NavType

Summary

Public companion properties

NavType<BooleanArray?>

NavType for storing boolean arrays, corresponding with the "boolean[]" type in a Navigation XML file.

Cmn

android

NavType<List<Boolean>?>

NavType for storing list of Booleans.

Cmn

android

NavType<Boolean>

NavType for storing boolean values, corresponding with the "boolean" type in a Navigation XML file.

Cmn

android

NavType<FloatArray?>

NavType for storing float arrays, corresponding with the "float[]" type in a Navigation XML file.

Cmn

android

NavType<List<Float>?>

NavType for storing list of Floats.

Cmn

android

NavType<Float>

NavType for storing float values, corresponding with the "float" type in a Navigation XML file.

Cmn

android

NavType<IntArray?>

NavType for storing integer arrays, corresponding with the "integer[]" type in a Navigation XML file.

Cmn

android

NavType<List<Int>?>

NavType for storing list of Ints.

Cmn

android

NavType<Int>

NavType for storing integer values, corresponding with the "integer" type in a Navigation XML file.

Cmn

android

NavType<LongArray?>

NavType for storing long arrays, corresponding with the "long[]" type in a Navigation XML file.

Cmn

android

NavType<List<Long>?>

NavType for storing list of Longs.

Cmn

android

NavType<Long>

NavType for storing long values, corresponding with the "long" type in a Navigation XML file.

Cmn

android

NavType<Int>

NavType for storing integer values representing resource ids, corresponding with the "reference" type in a Navigation XML file.

android

NavType<Array<String>?>

NavType for storing String arrays, corresponding with the "string[]" type in a Navigation XML file.

Cmn

android

NavType<List<String>?>

NavType for storing list of Strings.

Cmn

android

NavType<String?>

NavType for storing String values, corresponding with the "string" type in a Navigation XML file.

Cmn

android

Public functions

abstract operator T?

get(bundle: Bundle, key: String)

Get a value of this type from the savedState

android

abstract operator T?

get(bundle: SavedState, key: String)

Get a value of this type from the savedState

Cmn

abstract T

Parse a value of this type from a String.

Cmn

android

open T

parseValue(value: String, previousValue: T)

Parse a value of this type from a String and then combine that parsed value with the given previousValue of the same type to provide a new value that contains both the new and previous value.

Cmn

android

abstract Unit

put(bundle: Bundle, key: String, value: T)

Put a value of this type in the savedState

android

abstract Unit

put(bundle: SavedState, key: String, value: T)

Put a value of this type in the savedState

Cmn

open String

serializeAsValue(value: T)

Serialize a value of this NavType into a String.

Cmn

android

open String

android

open Boolean

valueEquals(value: T, other: T)

Compares two values of type T and returns true if values are equal.

Cmn

android

Public properties

open Boolean

Check if an argument with this type can hold a null value.

Cmn

android

open String

The name of this type.

Cmn

android

Public companion functions

fromArgType

open fun fromArgType(type: String?, packageName: String?): NavType<*>

Parse an argType string into a NavType.

Parameters
type: String?

argType string, usually parsed from the Navigation XML file

packageName: String?

package name of the R file, used for parsing relative class names starting with a dot.

Returns
NavType<*>

a NavType representing the type indicated by the argType string. Defaults to StringType for null.

Public companion properties

BoolArrayType

val BoolArrayTypeNavType<BooleanArray?>

NavType for storing boolean arrays, corresponding with the "boolean[]" type in a Navigation XML file.

Null values are supported. Default values in Navigation XML files are not supported.

BoolListType

val BoolListTypeNavType<List<Boolean>?>

NavType for storing list of Booleans.

Null values are supported. List NavTypes in Navigation XML files are not supported.

BoolType

val BoolTypeNavType<Boolean>

NavType for storing boolean values, corresponding with the "boolean" type in a Navigation XML file.

Null values are not supported.

FloatArrayType

val FloatArrayTypeNavType<FloatArray?>

NavType for storing float arrays, corresponding with the "float[]" type in a Navigation XML file.

Null values are supported. Default values in Navigation XML files are not supported.

FloatListType

val FloatListTypeNavType<List<Float>?>

NavType for storing list of Floats.

Null values are supported. List NavTypes in Navigation XML files are not supported.

FloatType

val FloatTypeNavType<Float>

NavType for storing float values, corresponding with the "float" type in a Navigation XML file.

Null values are not supported.

IntArrayType

val IntArrayTypeNavType<IntArray?>

NavType for storing integer arrays, corresponding with the "integer[]" type in a Navigation XML file.

Null values are supported. Default values in Navigation XML files are not supported.

IntListType

val IntListTypeNavType<List<Int>?>

NavType for storing list of Ints.

Null values are supported. List NavTypes in Navigation XML files are not supported.

IntType

val IntTypeNavType<Int>

NavType for storing integer values, corresponding with the "integer" type in a Navigation XML file.

Null values are not supported.

LongArrayType

val LongArrayTypeNavType<LongArray?>

NavType for storing long arrays, corresponding with the "long[]" type in a Navigation XML file.

Null values are supported. Default values in Navigation XML files are not supported.

LongListType

val LongListTypeNavType<List<Long>?>

NavType for storing list of Longs.

Null values are supported. List NavTypes in Navigation XML files are not supported.

LongType

val LongTypeNavType<Long>

NavType for storing long values, corresponding with the "long" type in a Navigation XML file.

Null values are not supported. Default values for this type in Navigation XML files must always end with an 'L' suffix, e.g. app:defaultValue="123L".

ReferenceType

val ReferenceTypeNavType<Int>

NavType for storing integer values representing resource ids, corresponding with the "reference" type in a Navigation XML file.

Null values are not supported.

StringArrayType

val StringArrayTypeNavType<Array<String>?>

NavType for storing String arrays, corresponding with the "string[]" type in a Navigation XML file.

Null values are supported. Default values in Navigation XML files are not supported.

StringListType

val StringListTypeNavType<List<String>?>

NavType for storing list of Strings.

Null values are supported. List NavTypes in Navigation XML files are not supported.

StringType

val StringTypeNavType<String?>

NavType for storing String values, corresponding with the "string" type in a Navigation XML file.

Null values are supported.

Public constructors

<T : Any?> NavType(isNullableAllowed: Boolean)
Parameters
<T : Any?>

the type of the data that is supported by this NavType

isNullableAllowed: Boolean

whether an argument with this type can hold a null value.

Public functions

get

abstract operator fun get(bundle: Bundle, key: String): T?

Get a value of this type from the savedState

Parameters
bundle: Bundle

savedState to get value from

key: String

savedState key

Returns
T?

value of this type

get

abstract operator fun get(bundle: SavedState, key: String): T?

Get a value of this type from the savedState

Parameters
bundle: SavedState

savedState to get value from

key: String

savedState key

Returns
T?

value of this type

parseValue

abstract fun parseValue(value: String): T

Parse a value of this type from a String.

Parameters
value: String

string representation of a value of this type

Returns
T

parsed value of the type represented by this NavType

parseValue

open fun parseValue(value: String, previousValue: T): T

Parse a value of this type from a String and then combine that parsed value with the given previousValue of the same type to provide a new value that contains both the new and previous value.

By default, the given value will replace the previousValue.

Parameters
value: String

string representation of a value of this type

previousValue: T

previously parsed value of this type

Returns
T

combined parsed value of the type represented by this NavType

put

abstract fun put(bundle: Bundle, key: String, value: T): Unit

Put a value of this type in the savedState

Parameters
bundle: Bundle

savedState to put value in

key: String

savedState key

value: T

value of this type

put

abstract fun put(bundle: SavedState, key: String, value: T): Unit

Put a value of this type in the savedState

Parameters
bundle: SavedState

savedState to put value in

key: String

savedState key

value: T

value of this type

serializeAsValue

open fun serializeAsValue(value: T): String

Serialize a value of this NavType into a String.

By default it returns value of kotlin.toString or null if value passed in is null.

This method can be override for custom serialization implementation on types such custom NavType classes.

Note: Final output should be encoded with NavUriUtils.encode

Parameters
value: T

a value representing this NavType to be serialized into a String

Returns
String

encoded and serialized String value of value

valueEquals

open fun valueEquals(value: T, other: T): Boolean

Compares two values of type T and returns true if values are equal.

Parameters
value: T

the first value for comparison

other: T

the second value for comparison

Public properties

isNullableAllowed

open val isNullableAllowedBoolean

Check if an argument with this type can hold a null value.

Returns
Boolean

Returns true if this type allows null values, false otherwise.

name

open val nameString

The name of this type.

This is the same value that is used in Navigation XML argType attribute.

Returns
String

name of this 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-02-19 UTC.