什么是ViewModelStore和viewModelStoreOwner?
由于这个新的ViewModelProvider api,我非常困惑(不推荐使用ViewModelProviders) 与新更改一样,也有新的构造函数(源代码)。 #1 public ViewModelProvider(@NonNull ViewModelStoreOwner owner) { this(owner.getViewModelStore(), owner instanceof HasDefaultViewModelProviderFactory ? ((HasDefaultViewModelProviderFactory) owner).getDefaultViewModelProviderFactory() : NewInstanceFactory.getInstance()); } #2 public ViewModelProvider(@NonNull ViewModelStoreOwner owner, @NonNull Factory factory) { this(owner.getViewModelStore(), factory); } #3 public ViewModelProvider(@NonNull ViewModelStore store, @NonNull Factory factory) { mFactory = factory; mViewModelStore = store; } 摇篮依赖度: implementation "androidx.lifecycle:lifecycle-extensions:2.2.0-rc02" …