forked from androidannotations/androidannotations
-
Notifications
You must be signed in to change notification settings - Fork 0
RoboGuiceIntegration
pyricau edited this page Nov 22, 2012
·
7 revisions
Since AndroidAnnotations 1.0
AndroidAnnotations fully integrates with RoboGuice 1.1.1.
If you have any problems integrating AndroidAnnotations with versions of RoboGuice superior to 1.1.1, please let us know so that we can fix it.
![]() |
![]() |
|---|
- Add AndroidAnnotations to your project.
- Add RoboGuice to your project.
- Instead of having activities that inherit from
RoboActivity, simply annotate them with@RoboGuice. - Looking for a working example ? Have a look RoboGuiceExample!
@EActivity(R.layout.main)
@RoboGuice({AstroListener.class, AnotherListener.class})
public class AstroGirl extends Activity {
@ViewById
EditText edit;
@Inject
GreetingService greetingService;
@Click
void button() {
String name = edit.getText().toString();
greetingService.greet(name);
}
}public class AstroListener {
@Inject
Context context;
public void doSomethingOnResume(@Observes OnResumeEvent onResume) {
Toast.makeText(context, "Activity has been resumed", Toast.LENGTH_LONG).show();
}
}RoboGuice brings the power of the Guice framework to your Android application. It means that you can benefit from dependency injection advantages : low coupling, higher maintainability.
- Compile time injection of Android components (=> no perf impact)
- Extending
RoboActivityis not needed any more. This basically mean that you can inherit from any activity class, even those not supported byRoboGuice. Think about it if you want to use other frameworks that require you to extends their own base activity class. - Support for
@Click,@Background,@UiThread,@UiThreadDelayed,@ItemSelected, etc.
AndroidAnnotations was created by Pierre-Yves Ricau and is sponsored by eBusinessInformations.
04/03/2013 The 2.7.1 release is out
- Get started!
- Download
- Cookbook, full of recipes
- List of all available annotations
- Release Notes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue
- Tag on Stack Overflow

