This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
After injection
Pierre-Yves Ricau edited this page Feb 2, 2012
·
4 revisions
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).
19/11/2020 The 4.8.0 release is out !
- Get started!
- Cookbook, full of recipes
- Customize annotation processing
- List of all available annotations
- Release Notes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue
- Tag on Stack Overflow
- Ask on Gitter