androidx.hilt.navigation


Top-level functions summary

ViewModelProvider.Factory
HiltViewModelFactory(
    context: Context,
    delegateFactory: ViewModelProvider.Factory
)

Creates a ViewModelProvider.Factory to get HiltViewModel -annotated ViewModel from a ViewModelProvider.Factory.

ViewModelProvider.Factory
HiltViewModelFactory(
    context: Context,
    navBackStackEntry: NavBackStackEntry
)

Creates a ViewModelProvider.Factory to get HiltViewModel -annotated ViewModel from a NavBackStackEntry.

Top-level functions

HiltViewModelFactory

fun HiltViewModelFactory(
    context: Context,
    delegateFactory: ViewModelProvider.Factory
): ViewModelProvider.Factory

Creates a ViewModelProvider.Factory to get HiltViewModel -annotated ViewModel from a ViewModelProvider.Factory.

Parameters
context: Context

the activity context.

delegateFactory: ViewModelProvider.Factory

the delegated factory.

Returns
ViewModelProvider.Factory

the factory.

Throws
kotlin.IllegalStateException

if the context given is not an activity.

HiltViewModelFactory

fun HiltViewModelFactory(
    context: Context,
    navBackStackEntry: NavBackStackEntry
): ViewModelProvider.Factory

Creates a ViewModelProvider.Factory to get HiltViewModel -annotated ViewModel from a NavBackStackEntry.

Parameters
context: Context

the activity context.

navBackStackEntry: NavBackStackEntry

the navigation back stack entry.

Returns
ViewModelProvider.Factory

the factory.

Throws
kotlin.IllegalStateException

if the context given is not an activity.

Discover the latest app development tools, platform updates, training, and documentation for developers across every Android device.

Updated Dec 18, 2024

Kotlin is Android's recommended programming language for modern android development.

Updated Mar 1, 2023

Kotlin is Android's recommended programming language for modern android development.

Updated Mar 7, 2023