Android Annotations and RoboGuice


Published on

  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • 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
  • Android Annotations and RoboGuice

    1. 1. AndroidAnnotationsRoboGuiceAndroid programing frameworksBy: Joel Sticha
    2. 2. AndroidAnnotationsAndroidAnnotations was created by Pierre-Yves Ricauand is sponsored by eBusinessInformations.
    3. 3. 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.
    4. 4. 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!
    5. 5. Is your Android code easy to write, read, andMaintain?
    6. 6. Applications already usingAndroidAnnotations:
    7. 7. 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_
    8. 8. RoboGuiceDependency Injection for AndroidCurrent Version is 2.0
    9. 9. What RoboGuice Does RoboGuice is a dependency injection framework for Android It uses the Google Guice framework as the backbone
    10. 10. Classic android
    11. 11. Class with RoboGuice
    12. 12. Example Program