Repository navigation
Enhancing the Application class
pyricau edited this page May 10, 2012
·
9 revisions
Since AndroidAnnotations 2.4
You can enhance your Android Application class with the @EApplication annotation:
@EApplication
public class MyApplication extends Application {
}You can then start using most AA annotations, except the ones related to views and extras:
@EApplication
public class MyApplication extends Application {
public void onCreate() {
super.onCreate();
initSomeStuff();
}
@SystemService
NotificationManager notificationManager;
@Bean
MyEnhancedDatastore datastore;
@RestService
MyService myService;
@Background
void initSomeStuff() {
// init some stuff in background
}
}You can inject the application class using the @App annotation:
@EActivity
public class MyActivity extends Activity {
@App
MyApplication application;
}It also works for any kind of annotated component, such as @EBean:
@EBean
public class MyBean {
@App
MyApplication application;
}You can inject your application class even if it has not been annotated with
@EApplication.
AndroidAnnotations was created by Pierre-Yves Ricau and was originally sponsored by eBusinessInformations.
10/07/2015 The 3.3.2 release is out !
- Get started!
- Download
- 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