belongs to Maven artifact androidx.lifecycle:lifecycle-viewmodel:2.0.0-alpha1

ViewModelProvider.AndroidViewModelFactory

public static class ViewModelProvider.AndroidViewModelFactory
extends ViewModelProvider.NewInstanceFactory

java.lang.Object
   ↳ androidx.lifecycle.ViewModelProvider.NewInstanceFactory
     ↳ androidx.lifecycle.ViewModelProvider.AndroidViewModelFactory


ViewModelProvider.Factory which may create AndroidViewModel and ViewModel, which have an empty constructor.

Summary

Public constructors

ViewModelProvider.AndroidViewModelFactory(Application application)

Creates a AndroidViewModelFactory

Public methods

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

Creates a new instance of the given Class.

static ViewModelProvider.AndroidViewModelFactory getInstance(Application application)

Retrieve a singleton instance of AndroidViewModelFactory.

Inherited methods

Public constructors

ViewModelProvider.AndroidViewModelFactory

ViewModelProvider.AndroidViewModelFactory (Application application)

Creates a AndroidViewModelFactory

Parameters
application Application: an application to pass in AndroidViewModel

Public methods

create

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

getInstance

ViewModelProvider.AndroidViewModelFactory getInstance (Application application)

Retrieve a singleton instance of AndroidViewModelFactory.

Parameters
application Application: an application to pass in AndroidViewModel

Returns
ViewModelProvider.AndroidViewModelFactory A valid ViewModelProvider.AndroidViewModelFactory