Learning Android Development

Passing Activity Intent Data to ViewModel through Injection

Passing Everything to ViewModel without Activity involvement.

Photo by Ben White on Unsplash

Since 2017 till now, with Architecture Component in place, ViewModel had come a long way. It is starting to replace Activity/Fragment as the core of the view, having the ability to interact with Views, able to emit signal using LiveData, and of last year able to Saved State.

This year, with Dagger Hilt, it now has the ability to be injected with Dependencies without involvement from the Activities.

However, with the above solution, nothing was mentioned about how we handle the Intent Data an activity received, to be sent to the ViewModel.

The three things sent to…

--

--