ViewModelProviders.of(this) is deprecated what to use instead ViewModelProviders.of(this) OR if you don't want to use ViewmodelFactory OR ViewModelProviders error.

 The problem:- 

1) Solution to Deprecated method ViewModelProviders#of 
2) As ViewModelProviders.of() is deprecated, How should i create object of ViewModel? 
3) Deprecated ViewModelProviders!
4) Remove deprecated ViewModelProviders.


 Try this:
 ViewModelProviders viewModel = ViewModelProviders.of(this)
            .get(AddActivityViewModel.class); // deprecated 

Change to this:
ViewModelProvider viewModel= new 
     ViewModelProvider(this).get(AddActivityViewModel.class); // New



Search By:

viewmodelproviders.of deprecated java   
android viewmodelprovider example  
viewmodelprovider example  
viewmodelproviders androidx  
viewmodelproviders.of(this) error 
viewmodelproviders.of activity  
viewmodelprovider(viewmodelstoreowner) viewmodelprovider factory  
android viewmodelprovider





Comments

Post a Comment

Popular posts from this blog

Android Studio 3.5 or above usb device not detected in Android Studio or Unable to detect adb version, exit value: 0xc0000135. ADB depends on the Windows Universal C Runtime, which is usually installed by default via Windows Update. You may need to manually fetch and install the runtime package here: https://support.microsoft.com/en-ca/help/2999226/update-for-universal-c-runtime-in-windows

Lint found fatal errors while assembling a release target.