@Retention(value=CLASS) @Target(value=FIELD) public @interface RootContext
Use it on Context fields in an EBean
annotated classes to inject context of the parent class.
This field may not be injected at runtime if the context used to create the
bean is not of the appropriate type. For example, if you create a new
instance of the bean using a Service context, and you use RootContext
on a field that extends Activity, this field will be null at runtime.
Example :
@EBean
public class MyClass {
@RootContext
Context context;
// Only injected if the root context is an activity
@RootContext
Activity activity;
// Only injected if the root context is a service
@RootContext
Service service;
// Only injected if the root context is an instance of MyActivity
@RootContext
MyActivity myActivity;
}
Copyright © 2010-2015. All Rights Reserved.