Developing Google Android Mobile Clients for Web Services: a Case Study
Total Page:16
File Type:pdf, Size:1020Kb
Facoltà di Ingegneria Corso di Studi in Ingegneria Informatica tesi di laurea specialistica Developing Google Android Mobile Clients for Web Services: a Case Study Anno Accademico 2007/2008 relatore Ch.mo prof. Stefano Russo correlatore Ing. Marcello Cinque candidato Vito Daniele Cuccaro matr. 885/83 1 “Anyone who has never made a mistake has never tried anything new.” Albert Einstein 2 A chi ha condiviso con me tratti di vita, lunghi o brevi, camminando al mio fianco e sorreggendomi quando inciampavo. To whoever shared with me stretches of life, long or short, walking by me and holding me up while I was stumbling. 3 DEVELOPING GOOGLE ANDROID MOBILE CLIENTS FOR WEB SERVICES: A CASE STUDY ........................................................................................................................... 1 Introduction .......................................................................................................................................................... 6 Chapter 1 - Web Services for a Service Oriented Architecture ............................................................ 8 1.1 Web Services: the latest evolution of distributed computing ................................................ 8 1.2 Key benefits and known challenges of Web Services ......................................................... 13 1.3 The basic operational model of Web Services .................................................................... 15 1.4 The SOA-based Web Services Architecture ....................................................................... 16 1.5 Web Services Communication Models .............................................................................. 17 1.6 Core Standards for Web Services ....................................................................................... 18 1.7 SOAP: the de facto standard for Web Services development and invocation ...................... 21 1.8 Apache Axis: a Java-Based SOAP implementation ............................................................ 24 Chapter 2 - The Google Android mobile platform ..................................................................................27 2.1 The Open Handset Alliance and the Android Challenge..................................................... 27 2.2 Android Software Stack ..................................................................................................... 29 2.3 The Dalvik Virtual Machine .............................................................................................. 32 2.4 Android Development Framework ..................................................................................... 33 2.5 Android Application Anatomy ........................................................................................... 34 2.6 The Android Manifest ....................................................................................................... 37 2.7 Android Application Lifecycle .......................................................................................... 40 2.8 Android APIs .................................................................................................................... 45 2.9 Android GUIs .................................................................................................................... 47 2.10 A kind of magic: R.java and project resources management............................................... 49 2.11 Developing for Android: design philosophy and best practices .......................................... 50 2.12 Paranoid Android: the Security Model ............................................................................... 54 2.13 Android and Web Services: state of the art ........................................................................ 56 Chapter 3 - ICAAS: an Interoperable Configurable Architecture for Accessing Sensor networks ........................................................................................................................................58 3.1 Wireless Sensor Networks: some basics............................................................................. 58 3.2 The ICAAS project within REMOAM: main goals and requirements ................................ 60 3.3 The ICAAS Architecture: interoperability features and software stack ............................... 61 3.4 ICAAS as a SOA: Web Services for client applications ..................................................... 64 3.5 ICAASMobile: a J2ME client for the framework ............................................................... 68 Chapter 4 - Case Study: Analysis, Design and Implementation of an Android client for ICAAS ............................................................................................................................................70 4.1 Analysis ............................................................................................................................ 71 4.1.1 ICAASMobile as a starting point: the steps of a typical porting process ......................... 71 4.1.2 Reverse engineering of the ICAASMobile client: understanding the initial application .. 77 4.2 Software Requirements Specification and Use cases .......................................................... 78 4.3 Object Oriented Analysis: Package Diagram and Class Diagram ....................................... 84 4.4 Design ............................................................................................................................... 87 4.4.1 Forward engineering of DroidICAASMobile: Validating the Original Design Plan and Deciding about Porting Strategies .................................................................................. 88 4.5 Invoking Web Services in Android: the KSOAP2 solution ................................................ 89 4.5.1 KSOAP: a SOAP open source client library for mobile Java-based devices ................... 90 4.5.2 Rewriting the ICAAS Stub: an example of code restructuring ........................................ 91 4 4.6 Porting the MVC Pattern to Android: a case of software reengineering .............................. 98 4.6.1 Model-View-Controller: separating GUI from Business Logic and Data Access ............ 99 4.6.2 AVA (Adapter-View-Activity): MVC, the Android way .............................................. 101 4.7 Object Oriented Design: Class Diagram and Package Diagram ........................................ 105 4.8 Implementation ............................................................................................................... 107 4.8.1 The Manifest and the main Activity ............................................................................. 107 4.8.2 Changing the Settings .................................................................................................. 111 4.8.3 Managing the sensors list: the AVA solution coded ..................................................... 112 Chapter 5 - DroidICAASMobile working: examples of use and scenarios .................................... 121 5.1 The Main Screen ........................................................................................................... 121 5.2 Scenario 1: Changing the Settings .................................................................................. 122 5.3 Scenario 2: Login and View of the Sensors List ............................................................. 123 5.4 Scenario 3: Selection of a Sensor of the List ................................................................. 125 5.5 Scenario 4: View of a Property of the current sensor ...................................................... 126 Chapter 6 - The Android Experience: a comparative critical analysis ........................................... 127 6.1 Getting started: prerequisites, initial problems and learning curve .................................. 127 6.2 Android and Java: which is the relationship? ................................................................. 129 6.3 J2ME vs Android: motivations for changing over .......................................................... 130 6.4 Android and the others: Symbian, iPhone and Windows Mobile .................................... 133 Conclusions ........................................................................................................................................................ 135 Future Works .................................................................................................................................................... 137 Appendix A ........................................................................................................................................................ 138 Appendix B ........................................................................................................................................................ 140 Appendix C ........................................................................................................................................................ 142 References ........................................................................................................................................................ 146 Acknowledgements .......................................................................................................................................... 147 5 Introduction This work was born a few months ago from the curiosity for the new mobile platform created by Google: Android. Many rumors had been around for