How to use FragmentFactory with Hilt

Ibrahim Yilmaz
2 min readJul 17, 2020
Photo by Clay Banks on Unsplash

Hi Android Fellas,

In this article, I will try to explain how we can use FragmentFactory in our project which uses Hilt as a Dependency Injection Library(visa versa).

Let’s get started:

We are familiar to do injection before onCreate method when we make use of Dagger like that:

Hilt promises us to handle most of boiler plate code blocks. This sounds amazing for us those who suffer from understanding Dagger.

Actually most of us directly jump into Dagger jungle without knowing what the dependency injection is and it is really sad to hear from my friends or other developers that “I will learn dagger, it is very handy and Google supports it” instead of learning Dependency Injection.

Sorry let’s get back to our topics! Yeah! even we don’t have to do component injection. This sounds the most amazing part!(But don’t worry we have to do it for multi-module projects. It is okay because we are used to it with Dagger).

--

--