当前位置: 代码迷 >> 综合 >> AndroidAnnotations——Injecting SystemServices注入系统服务
  详细解决方案

AndroidAnnotations——Injecting SystemServices注入系统服务

热度:76   发布时间:2023-12-12 00:00:56.0
AndroidAnnotation

目录(?)[+]

  1. SystemServices
    1. Standard Android System Service injection
    2. SystemService

SystemServices

Since AndroidAnnotations 1.0

Standard Android System Service injection


Retrieving Android System Services requires remembering the name of the constant, and casting the retrieved object.
获取Android System Service需要想起常量名,并且强制转换获得的对象。

notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

@SystemService


The @SystemService annotation indicates that an activity field should be injected with the corresponding Android System service .
@SystemService 注解表明activity 字段 应该由相应的Android System service 注入。

It is the same as calling the Context.getSystemService() method.
它和调用 Context.getSystemService() 方法起到了相同的作用。

Usage example:用法:

@EActivity
public class MyActivity extends Activity {
        @SystemServiceNotificationManager notificationManager;}
  相关解决方案