| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Since AndroidAnnotations 2.4
If you need to execute code at build time, after dependency injection, you should use the @AfterInject annotation on some methods.
@Enhanced
public class MyClass {
@SystemService
NotificationManager notificationManager;
@Inject
MyOtherClass dependency;
public MyClass() {
// notificationManager and dependency are null
}
@AfterInject
public void doSomethingAfterInjection() {
// notificationManager and dependency are set
}
}Or
@EActivity
public class MyActivity extends Activity {
@SystemService
NotificationManager notificationManager;
@Inject
MyOtherClass dependency;
public MyActivity() {
// notificationManager and dependency are null
}
@AfterInject
public void doSomethingAfterInjection() {
// 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).
| Back | FazBrowse Home | New Git URL |