-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Home
We want to facilitate the writing and the maintenance of Android applications.
We believe that simple code with clear intents is the best way to achieve those goals.
Robert C. Martin wrote in "Clean Code: A Handbook of Agile Software Craftsmanship":
The ratio of time spent reading [code] versus writing is well over 10 to 1. [...] Of course there’s no way to write code without reading it, so making it easy to read actually makes it easier to write.
While we all enjoy developing Android applications, we often wonder: Why do we always need to write the same code over and over? Why are our apps harder and harder to maintain? Context
and Activity
god objects, complexity of juggling with threads, hard to discover API, loads of anonymous listener classes, tons of unneeded casts... can't we improve that?
Using Java annotations, developers can show their intent and let AndroidAnnotations generate the plumbing code at compile time.
- Dependency injection: inject views, extras, system services, resources, ...
- Simplified threading model: annotate your methods so that they execute on the UI thread or on a background thread.
- Event binding: annotate methods to handle events on views, no more ugly anonymous listener classes!
- REST client: create a client interface, AndroidAnnotations generates the implementation.
- No magic: As AndroidAnnotations generate subclasses at compile time, you can check the code to see how it works.
- AndroidAnnotations provide those good things and even more for less than 150kb, without any runtime perf impact!
- Convinced? Get started!
- Curious? Read how it works
- Need proofs? See the apps already using AndroidAnnotations
- Looking for recipes? Read the cookbook
Is your Android code easy to write, read, and maintain?
Look at that:
@EActivity(R.layout.translate) // Sets content view to R.layout.translate
public class TranslateActivity extends Activity {
@ViewById // Injects R.id.textInput
EditText textInput;
@ViewById(R.id.myTextView) // Injects R.id.myTextView
TextView result;
@AnimationRes // Injects android.R.anim.fade_in
Animation fadeIn;
@Click // When R.id.doTranslate button is clicked
void doTranslate() {
translateInBackground(textInput.getText().toString());
}
@Background // Executed in a background thread
void translateInBackground(String textToTranslate) {
String translatedText = callGoogleTranslate(textToTranslate);
showResult(translatedText);
}
@UiThread // Executed in the ui thread
void showResult(String translatedText) {
result.setText(translatedText);
result.startAnimation(fadeIn);
}
// [...]
}
The project logo is based on the Android logo, created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.
Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions.
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