Android 12 Developer Preview is here! Try it out, and give us your feedback!

androidx.hilt.navigation

Top-level functions summary

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

Creates a ViewModelProvider.Factory to get dagger.hilt.android.lifecycle.HiltViewModel annotated ViewModel from a NavBackStackEntry.

Top-level functions

HiltViewModelFactory

@JvmName("create") fun HiltViewModelFactory(
    context: Context,
    navBackStackEntry: NavBackStackEntry
): ViewModelProvider.Factory

Creates a ViewModelProvider.Factory to get dagger.hilt.android.lifecycle.HiltViewModel annotated ViewModel from a NavBackStackEntry.

Parameters
context: Context the activity context.
navBackStackEntry: NavBackStackEntry the navigation back stack entry.
Return
the factory.
Exceptions
IllegalStateException if the context given is not an activity.