When developing Android projects, for example, we often need to use various View Controls, declare them, findviewbyid, and perform strong conversion. Every time you write such code, it is very cumbersome and error-prone. In this case, dependency injection can greatly reduce dependencies between classes and describe dependencies between classes through annotation (Java, this avoids directly calling similar constructors or using factory to participate in the required classes, which reduces coupling between classes or modules, improves code reuse and enhances code maintainability. Google guice provides a lightweight dependency injection framework on the Java platform and supports Android application development. The following describes how to use Google guice on the Android platform.
The basic usage has been explained. The following is a portal:
[1] use of the injection framework roboguice: (a brief example of what roboguice does)
[2] use of the injection framework roboguice: (your first view injection)
[3] use of the injection framework roboguice: (your first resource injection)
[4] use of the injection framework roboguice: (your first System Service injection)
[5] use of the injection framework roboguice: (your first pojo injection)
[6] use of the injection framework roboguice: (singletons and contextsingletons)
[7] use of the injection framework roboguice: (your first custom binding)
[8] use of the injection framework roboguice: (your first injected fragment)
[9] use of the injection framework roboguice: (your first injected service and broadcastreceiver)
[10] use of the injection framework roboguice: (your first testcase)
[11] use of the injection framework roboguice: (your first injection into a custom View class)
[12] use of the injection framework roboguice: (your first injected contentprovider)
[13] use of the injection framework roboguice: (logging via ln)
[14] injection framework roboguice usage Summary