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.
Kay-Uwe Janssen edited this page Oct 9, 2016
·
2 revisions
Calls for method with the same @AfterXXX annotation
The calling order of methods with the same annotation within a class cannot be guaranteed and you should NOT rely on it. If you want multiple methods be called in an ensured order, you should create one method that is annotated and use that to call the other methods in their desired order. If you have to deal with parent/child classes you could try this.
Example
@AfterInjectprotectedvoidcallInOrder() {
methodA();
methodB();
methodC();
}
privatevoidmethodA() {
// your code
}
privatevoidmethodB() {
// your code
}
privatevoidmethodC() {
// your code
}
Note: When @AfterExtras annotated methods are called, all injections that are not related to views are done. Therefore it is safe to use fields that are annotated with e.g. @Bean. The views are only available when the @AfterViews annotated methods get called.
Subsequent calls
@AfterExtras methods get called every time a new Intent reaches the Activity.
@AfterViews will be called everytime setContentView() is called. (Activity only)