added in version 1.1.0
belongs to Maven artifact android.arch.lifecycle:viewmodel:1.1.1

ViewModelProvider.AndroidViewModelFactory

public static class ViewModelProvider.AndroidViewModelFactory
extends ViewModelProvider.NewInstanceFactory

java.lang.Object
   ↳ android.arch.lifecycle.ViewModelProvider.NewInstanceFactory
     ↳ android.arch.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

added in version 1.1.0
ViewModelProvider.AndroidViewModelFactory (Application application)

Creates a AndroidViewModelFactory

Parameters
application Application: an application to pass in AndroidViewModel

Public methods

create

added in version 1.0.0
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

added in version 1.1.0
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