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 Activitygod objects, complexity of juggling with threads, hard to discover API, loads of anonymous listener classes, tons of unneeded casts... can't we improve that?Robert C. Martin (Uncle Bob)"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."
AndroidAnnotations has a little compilation overhead (how it works), but the generated classes are good old classic Android code. No reflection. No startup time, and no runtime impact.
Annotations do not need the id unless it differs from the java object name.Easy threading
My Examples will be using v1.1.1
AndroidAnnotationsRoboGuiceAndroid programing frameworksBy: Joel Sticha
AndroidAnnotationsAndroidAnnotations was created by Pierre-Yves Ricauand is sponsored by eBusinessInformations.
Why use android annotations? Goals We want to facilitate the writing and maintenance of android applications Android Annotations strives to achieve these goals by making code simple tounderstand with clear intents Robert C. Martin (Uncle Bob) "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." Using Java annotations, developers can show their intent and letAndroidAnnotations generate the plumbing code at compile time.
Features of AndroidAnnotations Dependency injection: inject views, extras, system services, resources, ... Simplified threading model: annotate your methods so that they execute onthe UI thread or on a background thread. Event binding: annotate methods to handle events on views, no more uglyanonymous listener classes! REST client: create a client interface, AndroidAnnotations generates theimplementation. AndroidAnnotations provide those good things and even more for less than50kb, without any runtime performance impact!
Is your Android code easy to write, read, andMaintain?
Android Annotations bottom line It takes out the most repetitive code in your application It helps you create cleaner code that is easier to read It can be included with small changes to your project and editing environment Add two jar files to the Java Build Path for your project. Add AndroidAnnotations as a annotation processor in the Java Compiler Settings Rename the activities to xxxx_
RoboGuiceDependency Injection for AndroidCurrent Version is 2.0
What RoboGuice Does RoboGuice is a dependency injection framework for Android It uses the Google Guice framework as the backbone