You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Pierre-Yves Ricau edited this page Feb 2, 2012
·
4 revisions
Since AndroidAnnotations 2.4
Executing code after dependency injection
If you need to execute code at build time, after dependency injection, you should use the @AfterInject annotation on some methods.
@EnhancedpublicclassMyClass {
@SystemServiceNotificationManagernotificationManager;
@InjectMyOtherClassdependency;
publicMyClass() {
// notificationManager and dependency are null
}
@AfterInjectpublicvoiddoSomethingAfterInjection() {
// notificationManager and dependency are set
}
}
Or
@EActivitypublicclassMyActivityextendsActivity {
@SystemServiceNotificationManagernotificationManager;
@InjectMyOtherClassdependency;
publicMyActivity() {
// notificationManager and dependency are null
}
@AfterInjectpublicvoiddoSomethingAfterInjection() {
// notificationManager and dependency are set
}
}
Please note that the view related injection hasn't occurred yet when @AfterInject methods are executed. You should use @AfterViews for such needs, see [Injecting Views](Injecting Views).