Tutorial by Examples

What is Dagger 2 ? The website describes itself as: Dagger is a fully static, compile-time dependency injection framework The library makes it easy to model dependency graphs as well as to reuse objects. Since reflection is only used at compile time as part of the annotation processing Dagger...
Define a module (the model of dependencies and their graph): @Module public class CoffeeModule{ @Provides public CoffeeMaker provideCoffeeMaker(){ return new CoffeeMaker(); } @Provides public Coffee provideCoffee(CoffeeMaker coffeeMaker){ return new ...
One of the central difficulties of writing an Android application using Dagger is that many Android framework classes are instantiated by the OS itself, like Activity and Fragment, but Dagger works best if it can create all the injected objects. Instead, you have to perform members injection in a li...
I have read and watched a lot of different Dagger2 tutorials but most of them are too long or hard to understand so I decided to write a new simple and short tutorial for Dagger2, I hope you like it. Why we need it? Simplifies access to shared instances: It provides a simple way to obtain refere...

Page 1 of 1