Skip to content
pyricau edited this page May 26, 2012 · 49 revisions

Goals

We want to facilitate the writing and the maintenance of Android applications.

How?

We believe that simple code with clear intents is the best way to achieve those goals. As Robert C. Martin said:

The ratio of time spent reading [code] versus writing is well over 10 to 1 [therefore] making it easy to read makes it easier to write.

simplify the Android development model, and

Our goal is to simplify the Android development model, and get rid of the unneeded complexity

Using Java annotations, developers can show their intent

Features

  • Simplified threading model: annotate your methods to ensure they'll be executed on the UI thread or on a background thread.
  • Event binding: annotate methods to handle events on views, no more ugly anonymous listener classes!
  • Dependency injection: inject views, extras, system services, resources, and even custom objects and let AndroidAnnotations take care of the details.
  • Rest client: define a client interface with a few annotations, and AndroidAnnotations takes care of the implementation details.
  • AndroidAnnotations provide those good things and even more for less than 50kb, without any runtime perf impact!

Next step

Code sample

Is your Android code easy to write, read, and maintain?

Here is how clear it will be with AndroidAnnotations:

@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.

Using AndroidAnnotations

Questions?

Enjoying AndroidAnnotations

Improving AndroidAnnotations

Clone this wiki locally