This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
SystemServices
Csaba Kozák edited this page Mar 16, 2016
·
9 revisions
Since AndroidAnnotations 1.0
Retrieving Android System Services requires remembering the name of the constant, and casting the retrieved object.
notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
The @SystemService
annotation indicates that an activity field should be injected with the corresponding Android System service.
It is the same as calling the Context.getSystemService() method.
Usage example:
@EActivity
public class MyActivity extends Activity {
@SystemService
NotificationManager notificationManager;
}
Since AndroidAnnotations 4.0.0
@EActivity
public class MyActivity extends Activity {
@SystemService
void setNotificationManager(NotificationManager notificationManager){
// do something with notificationManager
}
void setMultipleServices(@SystemService NotificationManager notificationManager, @SystemService AudioManager audioManager){
// do something with notificationManager and audioManager
}
}
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