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

AndroidViewModel

public class AndroidViewModel
extends ViewModel

java.lang.Object
↳ android.arch.lifecycle.AndroidViewModel


Application context aware ViewModel .

Subclasses must have a constructor which accepts Application as the only parameter.

Summary

Public constructors

AndroidViewModel(Application application)

Public methods

<T extends Application> T getApplication()

Return the application.

Inherited methods

From class android.arch.lifecycle.ViewModel
void onCleared()

This method will be called when this ViewModel is no longer used and will be destroyed.

From class java.lang.Object
Object clone()
boolean equals(Object arg0)
void finalize()
final Class<?> getClass()
int hashCode()
final void notify()
final void notifyAll()
String toString()
final void wait(long arg0, int arg1)
final void wait(long arg0)
final void wait()

Public constructors

AndroidViewModel

added in version 1.0.0
AndroidViewModel (Application application)

Parameters
application Application

Public methods

getApplication

added in version 1.0.0
T getApplication ()

Return the application.

Returns
T

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2025年02月10日 UTC.