forked from androidannotations/androidannotations
-
Notifications
You must be signed in to change notification settings - Fork 0
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
@AfterInjectmethods are executed. You should use@AfterViewsfor such needs, see [Injecting Views](Injecting Views).
AndroidAnnotations was created by Pierre-Yves Ricau and is sponsored by eBusinessInformations.
04/03/2013 The 2.7.1 release is out
- Get started!
- Download
- Cookbook, full of recipes
- List of all available annotations
- Release Notes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue
- Tag on Stack Overflow