For anyone having this question,
As per Android Documentation,
Since the ViewModel outlives specific activity and fragment instantiations, it should never reference a View, or any class that may hold a reference to the activity context. If the ViewModel needs the Application context (for example, to find a system service), it can extend the AndroidViewModel class and have a constructor that receives the Application in the constructor (since Application class extends Context).
Documentation can be found here : https://developer.android.com/topic/libraries/architecture/viewmodel.html
Edit: For duplicate explanation: I mean you can extend class to ViewModel as well as AndroidViewModel. When you should extend which, the above explanation is for that only. The links above tells about ViewModel of MVVM architecture in general and not the android.arch.lifecycle.ViewModel