This is the simplest Dagger Example for injecting in Android There are 8 example of using Dagger. All of them are very simple to understand if you follow chronologically. The examples are ,
- Inject SharedPreference using Dagger,
- If you want to inject an object in base activity (althought its not encouraged; doc: base classes are not sufficient as injection targets. Dagger 2 relies on strongly typed classes, so you must specify explicitly which ones should be defined.)
- Inject Custom SharedPreference Manager
- Inject Retrofit as Rest Client.
- Example of inject multiple onjects. In this case Rest Client and SharedPreference.
- Example of Qualified Types in Dagger. Basically if you want to inject different types of object of same type.
- Example of dependency in Dagger. A bit structure way to use Dagger. (doc: If we wish to have multiple components that do not need to remain in memory all the time (i.e. components that are tied to the lifecycle of an activity or fragment, or even tied to when a user is signed-in), we can create dependent components or subcomponents.)
- Example of SubComponent in Dagger. Doc: same as 7 All of them are in seperate branches.