in constructors or in onCreate() @AfterInject : non view attributes are injected @AfterViews : views are injected @AfterInject public void doSomethingAfterInjection() { } @AfterViews public void updateTextWithDate() { result.setText("Date: " + new Date()); }
Code generation at compile-time Each annotated class will have a generated subclass: public final class TranslateActivity_ extends TranslateActivity { ! // Ugly code you wish you would never have to write again }
1.Add in /libs androidannotations-X.X.X-api.jar 2.Add this jar to the project’s build path 3.Add in a directory /compile-libs the jar androidannotations-X.X.X.jar 4.In project properties: Java Compiler > Annotation Processing Enable annotation processing Java Compiler > Annotation Processing > Factory Path Add the processor androidannotations-X.X.X.jar
AndroidAnnotations logic. • Then quickly addictive... • A much more readable code. • Encourage to organize the code in modules. • Debugging : no difference. The generated code is not hidden.
injections + Injection more powerful than AndroidAnnotations - Injections are done during runtime ‣ Performance impact - Activities must extend RoboActivity ‣ Issue for using other libraries
offers more options on dependencies injection than AndroidAnnotation Injections also done during runtime Not Android exclusive but very light. A fast dependency injector for Android and Java.
Otto An enhanced Guava-based event bus with emphasis on Android support. Bus Post Subscribe bus.post(new AnswerAvailableEvent(42)); @Subscribe public void answerAvailable(AnswerAvailableEvent event) { }