Skip to content

Enhance custom classes

pyricau edited this page Jan 12, 2012 · 25 revisions

Since AndroidAnnotations 2.3

Documentation needed!

Meanwhile, have a look at @Enhanced.

Enhancing custom classes

You can use annotations in a class that is not a standard Android component (such as an Activity, a Service).

You just need to annotate it with @Enhanced:

@Enhanced
public class MyClass {

}

Injecting enhanced classes

To use this enhanced class in another enhanced class or in an enhanced Android component, use @Inject:

@Enhanced
public class MyOtherClass {

  @Inject
  MyClass myClass;

}

Notice how you can chain dependencies:

@EActivity
public class MyActivity extends Activity {

  @Inject
  MyOtherClass myOtherClass;

}

Supported annotations

@RootContext

Using AndroidAnnotations

Questions?

Enjoying AndroidAnnotations

Improving AndroidAnnotations

Clone this wiki locally