It's happening now, watch the livestream.

AbstractSavedStateVMFactory

public abstract class AbstractSavedStateVMFactory
extends Object implements ViewModelProvider.Factory

java.lang.Object
   ↳ androidx.lifecycle.AbstractSavedStateVMFactory


Skeleton of androidx.lifecycle.ViewModelProvider.KeyedFactory that creates SavedStateHandle for every requested ViewModel. The subclasses implement create(String, Class, SavedStateHandle) to actually instantiate ViewModels.

Summary

Public constructors

AbstractSavedStateVMFactory(SavedStateRegistryOwner owner, Bundle defaultArgs)

Constructs this factory.

Public methods

abstract <T extends ViewModel> T create(String key, Class<T> modelClass)

Creates a new instance of the given Class.

final <T extends ViewModel> T create(Class<T> modelClass)

Creates a new instance of the given Class.

Protected methods

abstract <T extends ViewModel> T create(String key, Class<T> modelClass, SavedStateHandle handle)

Creates a new instance of the given Class.

Inherited methods

Public constructors

AbstractSavedStateVMFactory

public AbstractSavedStateVMFactory (SavedStateRegistryOwner owner, 
                Bundle defaultArgs)

Constructs this factory.

Parameters
owner SavedStateRegistryOwner: SavedStateRegistryOwner that will provide restored state for created ViewModels

defaultArgs Bundle: values from this Bundle will be used as defaults by SavedStateHandle passed in ViewModels if there is no previously saved state or previously saved state misses a value by such key

Public methods

create

public abstract T create (String key, 
                Class<T> modelClass)

Creates a new instance of the given Class.

Parameters
key String: a key associated with the requested ViewModel

modelClass Class: a Class whose instance is requested

Returns
T a newly created ViewModel

create

public final T create (Class<T> modelClass)

Creates a new instance of the given Class.

Parameters
modelClass Class: a Class whose instance is requested

Returns
T a newly created ViewModel

Protected methods

create

protected abstract T create (String key, 
                Class<T> modelClass, 
                SavedStateHandle handle)

Creates a new instance of the given Class.

Parameters
key String: a key associated with the requested ViewModel

modelClass Class: a Class whose instance is requested

handle SavedStateHandle: a handle to saved state associated with the requested ViewModel

Returns
T a newly created ViewModels