1. Are you ready for the Galaxy S20? Here is everything we know so far!

Android Studio wizard generates code with obsolete calls?

Discussion in 'Android Development' started by jstuardo, Apr 19, 2020.

  1. jstuardo

    jstuardo Lurker
    Thread Starter

    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
     


Loading...
Similar Threads - Android Studio wizard
  1. Gleis
    Replies:
    0
    Views:
    55
  2. Syeda Quratulain
    Replies:
    1
    Views:
    425
  3. Sheraz Ahmed
    Replies:
    0
    Views:
    234
  4. Nieve1
    Replies:
    0
    Views:
    358
  5. docco2020
    Replies:
    1
    Views:
    514
  6. lovingdog
    Replies:
    0
    Views:
    642
  7. Gleis
    Replies:
    4
    Views:
    833
  8. emamsa
    Replies:
    0
    Views:
    465
  9. saran ks
    Replies:
    0
    Views:
    378
  10. mdsousa
    Replies:
    0
    Views:
    509

Share This Page

Loading...