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
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...
Similar Threads - Android Studio wizard
  1. White_Rabbit
    Replies:
    1
    Views:
    240
  2. workbench
    Replies:
    2
    Views:
    403
  3. thkl
    Replies:
    2
    Views:
    354
  4. brentc
    Replies:
    1
    Views:
    352
  5. brentc
    Replies:
    3
    Views:
    408
  6. hex1364
    Replies:
    0
    Views:
    356
  7. parthag
    Replies:
    0
    Views:
    326
  8. grellocj
    Replies:
    3
    Views:
    561
  9. Castino
    Replies:
    1
    Views:
    445
  10. PascalAuger
    Replies:
    16
    Views:
    1,332

Share This Page

Loading...