• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Android Studio wizard generates code with obsolete calls?

jstuardo

Lurker
Hello,

I used the Android Studio to generate an app with a Login activity.

One thing called my attention.

One line of code is:

loginViewModel = ViewModelProviders.of(this, new LoginViewModelFactory())
.get(LoginViewModel.class);

Android Studio shows ViewModelProviders.of as Deprecated. Why is that? why last version of Android Studio generates deprecated code? isn't it supposed that Android Studio should generate code following best practices? best practices include code that is not obsolete.

Searching in Internet, I have found it can be replaced with:

loginViewModel = ViewModelProviders.of(this).get(LoginViewModel::class.java)

That is, can I remove LoginViewModelFactory class? Shouldn't I use wizards as a starting point of the application?

Any advice will be greatly appreciated.

Regards
 
Back
Top Bottom