Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Feed your Android with a REST client

Feed your Android with a REST client

Introduction to Android programming during the "Exchange Programme Summer 2013" with Hong Kong Baptist University. It talks about basic Android functionality and some design pattern to query REST APIs. Then there is an introduction to Android Volley library.

Source code of the workshop is available at: https://github.com/emanuele-palazzetti/HungryDroid

Emanuele Palazzetti

July 12, 2013
Tweet

More Decks by Emanuele Palazzetti

Other Decks in Technology

Transcript

  1. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Feed your Android with a REST client (all references are purely coincidental) Emanuele Palazzetti :: Google Developer Group
  2. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Who am I? Emanuele Palazzetti  @palazzem  evonove.it/authors/palazzem  github.com/emanuele-palazzetti
  3. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Do you know what GDG is?
  4. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Google Developer Group - Perugia  @GDGPerugia  perugia.gtugs.org  [email protected]
  5. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia What is Android? It's not a killing machine...
  6. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia ...but something very cool!
  7. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia More informations SDK is open source and is available for all main operative systems No license fees, no certification or registration required to develop your apps
  8. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia More technical details It's based on kernel Linux 2.6 and on 3.x from Ice Cream Sandwich version (Android > 4.0) API used to build the Android system are the same that are used by developers Almost all of basic components can be replaced with your or 3rd party application (ex: Skype, Viber, WhatsApp, etc..). There are some exception to avoid security issues The code is open source released as Apache License 2.0
  9. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Android  Java The entire operative system and all built-in and third party apps are built with Java language Doesn't use standard JVM but a Dalvik VM It is possibile to call C/C++ code via JNI Kivy framework allows to write Python applications
  10. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Application layer (Activity) An Activity is an application component that provides a screen with which users can interact (dial phone, photos,...) Each activity is given a window in which to draw its user interface. There is an Activity Stack where new activities are pushed on top Only one Activity at the same time can runs
  11. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Many other components Services AsyncTask Broadcast receivers Content providers ...
  12. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Start speaking about workshop
  13. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia What do I want? I have a web service which exposes some REST APIs I want to build and Android application which uses these APIs
  14. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia About REST APIs We have resources with a global identifier (ex: URI) To manipulate you can use a standardized interface (ex: HTTP) We can use HTTP methods (GET, PUT, POST, DELETE) Tipically the returned information is JSON, XML, etc...
  15. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Example {"message": "Hello world!"}
  16. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Our APIs (Django application) http://students-exam.herokuapp.com/admin/ http://students-exam.herokuapp.com/api/exam/.json
  17. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia What design pattern to use?
  18. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Don't use it!
  19. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Another pattern...
  20. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia ...another one (a foo pattern)...
  21. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia ...too many design patterns!
  22. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Brilliant! Why not use a library for that?!
  23. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Remember: Design patterns are really important!
  24. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Volley library Used by Google inside Play Store Automatically schedule all network requests (even images) Provides transparent disk and memory caching Powerful cancellation request API https://android.googlesource.com/platform/frameworks/volley
  25. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Android distribution http://developer.android.com/about/dashboards/index.html
  26. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Workshop time! https://www.tofu.st/palazzem/Android_stuff/logo_unipg.png https://www.tofu.st/palazzem/Android_stuff/volley.zip
  27. Feed your Android with a REST client Emanuele Palazzetti ::

    Google Developer Group Perugia Emanuele Palazzetti :: Google Developer Group  @palazzem  evonove.it/authors/palazzem  github.com/emanuele-palazzetti/HungryDroid