Stay organized with collections Save and categorize content based on your preferences.

AndroidViewModel

public class AndroidViewModel extends ViewModel


Application context aware ViewModel.

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

Summary

Public constructors

Public methods

@NonNull T
<T extends Application> getApplication()

Return the application.

Inherited methods

From androidx.lifecycle.ViewModel
void

Add a new Closeable object that will be closed directly before onCleared is called.

void

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

Public constructors

AndroidViewModel

public AndroidViewModel(@NonNull Application application)

Public methods

getApplication

public @NonNull T <T extends Application> getApplication()

Return the application.