跨组织活动的Android组件ViewModel
作者:互联网
在Android Components中我可以将应用程序类作为ViewModel的所有者,所以我在几个活动中使用它吗?
还是没有走动?
ViewModelProviders.of(application class not activity).get(MyViewModel.class);
解决方法:
应用程序不是LifecycleOwner,因此您不能将其用作ViewModel的范围.
标签:android,android-viewmodel,android-components 来源: https://codeday.me/bug/20190705/1388431.html