@HansPeter
Nothing here yet.
Nothing here yet.
No blogs yet.
I tried to implement your solution but it does not seem to work. Do you have any idea what Im doing wrong? What I did: Added implementation "androidx.fragment:fragment-ktx:1.3.6" My Android View Model constructor looks like this: class MainViewModel(private val app: Application, webApiRepository: IWebApiRepository = WebApiRepository.getInstance(app)) : ViewModelProvider.AndroidViewModelFactory(app) I also added the create function: override fun <T : ViewModel> create(modelClass: Class<T>): T { if (modelClass.isAssignableFrom( MainViewModel::class.java)) { return MainViewModel(app, webApiRepository) as T } throw IllegalArgumentException("Unknown ViewModel class") } But when I try to use by activityViewModels or viewModels it does not work: (Remove the two empty spaces) https:// cdn.hashnode .com/res/hashnode/image/upload/v1657015361719/7gYkfO5k8.png I need to use activityViewModel in order to get a shared ViewModel across fragments. Thanks