development with modern mobile technologies

39
Development with Modern Mobile Technologies Bj¨ orn Dahlgren [email protected] NiklasStr¨om [email protected] KTH Kista, Stockholm, September 2, 2011 1

Upload: others

Post on 03-Feb-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Development with Modern Mobile Technologies

Development with Modern Mobile Technologies

Bjorn [email protected]

Niklas [email protected]

KTH Kista, Stockholm, September 2, 2011

1

Page 2: Development with Modern Mobile Technologies

Abstract

In this report we evaluate modern mobile development technologies by producing criteria forthe evaluation. We gathered the criteria by conducting a study of popular applications alreadydeveloped. From these criteria we decided to evaluate development for Android, iOS as well as forweb applications. The evaluation was made by making a simple application fetching data from anAPI of the courses available at KTH, as well as course information and schedule for the courses. Ourconclusions were that if the application is simple, it may not be worth actually making it a nativeapplication.

2

Page 3: Development with Modern Mobile Technologies

Contents

1 Introduction 51.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.1.1 iOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.1.2 Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.1.3 Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.1.4 Cross-platform native development . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.2 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.3 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2 Application Fundamentals 72.1 MVC - Model, View, Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2 Data formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.2.1 JSON - JavaScript Object Notation . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2.2 XML - eXtensible Markup Language . . . . . . . . . . . . . . . . . . . . . . . . . . 102.2.3 Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

3 Mobile Technologies 113.1 Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3.1.1 System Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.1.2 Development tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.1.3 Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.1.4 Fragmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.1.5 Handling Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.1.6 Views and Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.1.7 Threading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.1.8 Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

3.2 iOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.2.1 System Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.2.2 Views and Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.2.3 Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.2.4 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.2.5 Limitations of the iOS platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

3.3 Web Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.3.1 jQuery Mobile and jQTouch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

4 Methodology 174.1 Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

4.1.1 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.1.2 Evaluation of criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

4.2 Toolset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

5 Procedure 215.1 Backend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

5.1.1 Courses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.2 Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

5.2.1 Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.2.2 Internet Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.2.3 Local Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225.2.4 Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

5.3 iOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225.3.1 Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225.3.2 Internet Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235.3.3 Local Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245.3.4 Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

5.4 Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255.4.1 Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255.4.2 Internet Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3

Page 4: Development with Modern Mobile Technologies

5.4.3 Local Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255.4.4 Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

6 Results 276.1 Backend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276.2 Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276.3 iOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276.4 Web Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

7 Analysis 337.1 Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337.2 Third Party Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337.3 Internet Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337.4 Local Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337.5 Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337.6 Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

8 Conclusions 35

9 Bibliography 37

10 Attachments 3910.1 iOS Top 50 Free Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

List of Figures

1 Model of the MVC pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 JSON object definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 JSON array definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 JSON value definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 JSON string definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 JSON number definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Android Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 iOS Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Basic components of most popular applications . . . . . . . . . . . . . . . . . . . . . . . . 1910 Android - Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2811 Android - Filtered Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2812 Android - Course Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2913 Android - Schedule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2914 iOS - Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3015 iOS - Filtered Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3016 iOS - Course Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3117 iOS - Schedule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3118 jQTouch - My Courses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3219 jQTouch - Course Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

List of Tables

1 Time consumption comparison between JSON and XML . . . . . . . . . . . . . . . . . . . 102 Filtered top 50 free applications with common features analyzed . . . . . . . . . . . . . . 18

4

Page 5: Development with Modern Mobile Technologies

1 Introduction

1.1 Background

Since the release of the iPhone in 2007 the market for applications in smartphones has exploded. Accord-ing to Gartner’s latest statistics, the market shares of smartphones are still increasing drastically [22].

There are many different techniques and environments used to develop applications for the differenttypes of mobile platforms out in the public today.

1.1.1 iOS

iOS revolutionized the smartphone concept making it a mainstream type of device. Apple had greatimpact on the usage of mobiles with it’s iPhone. Statistics from such sites as Flickr shows the popularityof the iOS devices, it’s the most popular camera device, more than professional cameras [21].

Four major versions of iOS have been release so far with a fifth planned for this fall. The first versionof iOS didn’t feature any dedicated app store and instead allowed developers to create web-based ap-plications. Before iOS4 only one application was allowed to run at the same time which made someapplications less user friendly. Third party music players such as Spotify and Pandora were shut downwhen replying to a SMS or using any other application whereas the iTunes music player could be back-grounded.

One of the main features of the iOS platform is the App Store. As of January 2011 there are over 350000 applications for iPhone in the App Store and more than 60 000 for the Apple iPad [3]. There areboth free and paid apps that can be downloaded onto the users iOS device.

1.1.2 Android

Android is a Linux-based mobile platform primarily developed by Google. Android Inc was founded in2003 and acquired by Google in 2005. Rumors started floating that Google where working on a ”GooglePhone”, focusing on searching and user preferences. In November 2007 the Open Handset Alliance wasannounced, consisting of major companies related to phone manufacturing. Their first product releasedwas Android, an open source mobile platform available for all manufacturers.

October 2008 saw the first release of an Android phone, the HTC Dream, also referred to as AndroidDeveloper Phone 1 or T-Mobile G1. It shipped with Android 1.0 which was released about a monthearlier to developers. During 2009 three major releases occurred, 1.5, 1.6 and 2.1. Development sincethen has not slowed down, 2010 gave birth to more major releases.

In 2011, Android 3.0 ”Honeycomb” started shipping with a few selected tablets, featuring a brand newUI. There has been some discussion regarding if Google will allow manufacturers to ship Android 3.0devices with custom UI like HTC Sense or Samsung Touchwiz. Google has yet to release the source codefor 3.0 which has lead to some debate regarding the openness of the Android project. Andy Rubin, VPof Engineering at Google, recently explained that they had no intentions of locking out customizationsof the UI or withholding the source code [37]. Instead, they felt a need to clean up the code and adaptthe new UI for devices smaller than tablets.

1.1.3 Web

Web applications have existed for a quite a while. In the nineties operators tried to convince users touse WAP, websites optimized for small mobile devices. Back then cellphones only network capabilitywere GSM which didn’t allow for fast transfer rates but this has changed with the wide coverage of wifinetworks and faster mobile networks such as 3G and LTE. Smartphones now also have larger screens,which enhances the ability to browse the web.

Web-based applications has emerged as a quick and simple way to support multiple platforms. Withrecent support for HTML5, a lot of previous native only features are now accessible in a web browser.

5

Page 6: Development with Modern Mobile Technologies

Video, music, location and offline storage all are part of the HTML5 standard [41]. For applicationsthat requires even more native features there are frameworks such as PhoneGap which allows a webapplication to interface with device specific features [34].

1.1.4 Cross-platform native development

Most of the current mobile platforms each have their own SDKs and languages which puts a burdenon the development team if multiple platforms are targeted in a project. To increase code reusability,there are a number of development environments with an intermediate language which is adapted andcompiled to the target platform. Some examples of frameworks are,

• Appcelerator Titanium [2] - HTML, JavaScript

• MonoDroid [31], MonoTouch [32], Xamarin [42] - .NET

• MoSync [30] - C/C++

• PhoneGap [34] - HTML, Javascript

One major drawback of most cross-platform frameworks is the lack of native UI.

1.2 Objective

The objective of our report is to evaluate mobile development technologies for smartphones. The evalu-ation will be based on criteria gathered by doing a study of popular applications.

1.3 Acknowledgements

Christian Schulte for being an excellent inspiration during our hardship.

6

Page 7: Development with Modern Mobile Technologies

2 Application Fundamentals

2.1 MVC - Model, View, Controller

MVC is an abstraction pattern to increase security and modularity. It consists of three components,Model, View and Controller. The model defines and contains the data, which is requested by the con-troller. The View displays the contents of a model and handles the user interface.The controller handlesthe requests gathered from the view and maps the interaction between the view and the model [39].

Figure - 2 shows a model of the MVC pattern [39].

Figure 1: Model of the MVC pattern

2.2 Data formats

There are a number of standardized data formats for mobile usages. We’ve decided to analyze the twomost common, JSON and XML.

2.2.1 JSON - JavaScript Object Notation

JavaScript Object Notation was introduced in 2006 by Douglas Crockford as ”a lightweight, text-based,language-independent data interchange format” [15]. The syntax is the same JavaScript uses for objectcreation - JSON is therefor often seen as a subset of JavaScript. Figures 2 - 6 describes the valid syntaxfor the different data types allowed in JSON [27].

Figure 2: JSON object definition

7

Page 8: Development with Modern Mobile Technologies

Figure 3: JSON array definition

Figure 4: JSON value definition

Figure 5: JSON string definition

8

Page 9: Development with Modern Mobile Technologies

Figure 6: JSON number definition

9

Page 10: Development with Modern Mobile Technologies

JSON XMLNumber of objects 1000000 1000000Total Time (ms) 78257.9 4546694.78Average Time (ms) 0.08 4.55

Table 1: Time consumption comparison between JSON and XML

2.2.2 XML - eXtensible Markup Language

XML consists of tags with attributes. Data is derived from the root tag. The XML is more verbosecompared to the JSON data format. This leads to an overhead in the information transfer but it’spossible to avoid with compression methods such as gzip. A simple XML file might look like:

<?xml version="1.0" encoding="UTF-8" ?>

<items>

<item attribute="something">name of item 1</item>

<item attribute="something else ">name of item 2</item>

</items>

2.2.3 Comparison

In the case study by Nurseitov, benchmarks were performed comparing both resource utilization aswell as time efficiency [33]. These benchmarks showed that JSON is both faster as well as using fewerresources. Table - 1 depicts the results they gathered.

10

Page 11: Development with Modern Mobile Technologies

3 Mobile Technologies

3.1 Android

3.1.1 System Architecture

Android is a Linux-based Operating System. It uses a customized Linux 2.6 kernel with optimizationregarding power-usage and security for mobile platforms. Applications for the Android platform arewritten in Java but compiled into Dalvik executables, which are run on the Dalvik Virtual Machine ontop of the Linux kernel [14, p. 33]. Included with Android is quite a lot of libraries and frameworks foraccessing both software and hardware like notification services and cameras on the devices. Figure 7shows the different levels of the architecture [17].

3.1.2 Development tools

Development for the Android Platform is possible on Windows, Mac OSX and Linux. Included with theSDK for all platforms are debugging tools, the Android libraries, an emulator based on QEMU, Androiddocumentation and some specific tools for Dalvik compiling and packaging into Android Packages, APKs.These packages are signed with either a debug-key for testing or a production-key. The signed APK caneither be distributed by the creator himself by email or similar means of communication or published toone of the many marketplaces for Android applications, Google’s own or a third party market.

The official development tools recommended by Google are Eclipse with some specialized plugins forAndroid called ADT, Android Development Tools [16]. These eases the usage of the Android SDK toolssuch as deployment and debugging applications on the emulator or a developers phone. It also helpswith packaging applications into APKs. JetBrains IntelliJ IDEA latest community edition also shipswith their own integration with the Android SDK but lacks the GUI editors that ADT provides withEclipse.

Figure 7: Android Architecture

11

Page 12: Development with Modern Mobile Technologies

3.1.3 Versions

• 1.5 ”Cupcake” had a reworked and much better API. A proper Bluetooth stack was imple-mented [14, p. 13].

• 1.6 ”Donut” added support for multiple screen sizes and scaling of UI elements [14, p. 13].

• 2.1 ”Eclair” featured a reworked UI experience such as improved contact and mail handling. We-bKit got better support for HTML5-tags which allowed more advanced web applications. TheBluetooth stack is now compatible with Bluetooth 2.1 [14, p. 13].

• 2.2 ”Froyo” brought Flash support on Android allowing both Flash content on the Web and thirdparty Flash applications. JIT, just-in-time compilation, was added on the Dalvik VM which gavea great performance increase in many applications.

• 2.3 ”Gingerbread” did not bring much for the user except for a more black and green UI. Somebehind the scene work was done such as a concurrent garbage collector. Support for NFC, NearField Communication, such as RFID.

3.1.4 Fragmentation

Due to the many versions of Android, applications must support different levels of APIs [18]. Thereare also a number of different hardware configurations, mainly screen sizes and resolutions [19]. To easedevelopment for multiple devices, which is the most common situation, there are a couple of mechanismsin place. It’s possible to query device format, screen size and screen density programmatically but apreferred way is by organizing resources for each device type.

3.1.5 Handling Resources

Images and other static content are organized as either resources, drawables or assets. Assets are includedwith the APK for runtime handling while drawable and resources are compiled into a binary format forfaster usage. A drawable can be either a standard image file or graphics defined with XML. Resourcesare often predefined layouts used to describe views for an Activity. Localization is also easily handledby making an XML containing the strings for each language. Android is built to easily support bothlocalization and different kind of devices by using predefined folders for languages and screen types.Instead of having to programmatically load different images and strings for each of these, Android doesthis for you [14, p. 267].

3.1.6 Views and Controllers

Android applications are based on different Activities. These act as controllers for Views, consisting ofeither default Android widgets or user created ones. Message passing between Activities uses a conceptcalled Intent which allows different data packages to be sent, either when starting a new Activity or whenfinishing and returning data to the callee. Intents can also be broadcasted to all registered receivers onthe device, allowing each to decide if it should handle the data or just let it go. They are also usedfor some user generated actions when sharing content between different applications such as sending apicture from the image gallery.

3.1.7 Threading

One important factor which is enforced by the OS is threading. Applications are not allowed to executecode in the UI-thread which takes longer than 5 seconds before yielding and responding to UI eventsagain [1, p. 81]. This is to ensure that the ”look and feel” is never deemed as slow or that the devicehas crashed or similar. If this requirement is not fulfilled, the user will be notified that the applicationhas not responded as intended and a choice to quit it the application is presented. To simplify usageof threading without learning how Java’s thread pool and/or threads works, a class called AsyncTask isincluded in the library. By extending the class and overriding the class methods, the developer can easily

12

Page 13: Development with Modern Mobile Technologies

spawn multiple threads that both interacts properly with the UI-thread and runs the main workload ina separate thread.

3.1.8 Permissions

Android has a built in permissions system to which applications must comply. The developer specifiesrequired permissions for the application to work properly and when the application is installed the enduser will be notified. Examples of permissions are read messages, access network and camera usage [14,p. 41].

3.2 iOS

iOS is based on Apple’s Cocoa Touch library which uses Objective-C as it’s main language. This mightscare away programmers since it has a quite different syntax compared to other mainstream languages.Like C++, the programmer must also manage all memory although there are some functionalities tohelp ease the burden.

3.2.1 System Architecture

The iOS platform is derived from Apple’s desktop OS, OSX. The main difference between the two systemsis the top layer of the architecture, OSX uses Cocoa while iOS has it’s own Cocoa Touch [29, p. 44].iOS includes a couple of system libraries such as UI, Audio and Location. These frameworks works asabstraction for the underlaying kernel and hardware, accessible through the API. A simple model of thearchitecture is shown in figure 8.

3.2.2 Views and Controllers

Apple implements the view and controller parts of the MVC pattern with UIViews and UIViewControllers [7].

Apple describes a UIView as a class that ”... defines a rectangular area on the screen and the interfaces formanaging the content in that area ... More sophisticated content can be presented by subclassing UIView

... For example, a UILabel object draws a text string and a UIImageView object draws an image.”, bothUILabel and UIImageView are subclasses of UIView [11].

UIViews have the ability to add subviews creating a hierarchy. For example the UITableView - iOSdefault list view - is basically implemented as a UIScrollView, which in turn is just a UIView withadded functionality for scrolling. To this scrollview subviews are later added for each UITableViewCell.Inside the UITableViewCells UILabels or other views are added [10].

UIViewControllers add features to UIViews. There are a bunch of ready made UIViewControllerswhich you can subclass - for instance the UITableViewController which comes with certain usefulmethods of controlling a UITableView. For instance it provides the data, perhaps by fetching from adatabase or a model object, and how it should present the informations in the UITableViewCells. The

Figure 8: iOS Architecture

13

Page 14: Development with Modern Mobile Technologies

UIViewControllers also provides methods for functionality. In the case of the UIScrollView, API forscrolling and events for when scrolling occurs.

3.2.3 Memory Management

As we mentioned earlier Objective c have several similarities to c and c++. One of the main factorsthat cause problems for programmers starting with iOS programming is the fact that you have to controlmemory management all by your self. Memory management is all about owning variables. As Appledescribes it ”You take ownership of an object if you create it using a method whose name begins with“alloc”, “new”, “copy”, or “mutableCopy” (for example, alloc, newObject, or mutableCopy), or if yousend it a retain message” [9]. This means the retain count of that object is incremented. Apple describesrelinquishing ownership as You use release or autorelease to relinquish ownership of an object. autoreleasejust means “send a release message in the future” [9]. When releasing you decrement the retain count ofthe object in question.

When the retain count reaches zero the object is deallocated and removed - if you try to use the variablenow you will get an error and the application will die.

What many people struggle with is both not releasing enough - which causes memory leak and eventuallylow memory warnings, but also releasing too much. At first glance it may seem simple to know that ifyou retained a variable you should release it and not otherwise - but there are many convenience methodsin the iOS API and it’s easy to make the mistake and think that they are retaining when they don’t andvice versa.

For example creating a string you may use two different methods - doing the same thing, but one retainsand the other does not.

NSString *string = [[NSString alloc] initWithFormat:@".."];

NSString *string = [NSString stringWithFormat:@".."];

In case of the first example we actually retain the variable - which we can see because we are usingalloc. The second case actually adds the variable to the autorelease pools which will be release later -for example at the end of the function. If you try to access that variable in a different function later -you will get an error saying you tried to access an already release variable.

The second case is actually a convenient way of saying the following:

NSString *string = [[[NSString alloc] initWithFormat:@".."] autorelease];

But the point of the matter is that unless you are consistent with which way you chose to initializememory you might reach trouble later or in the development process. Either by having a lot of memoryleaks which may be difficult to debug or by getting errors that can be quite hard to figure out.

3.2.4 Tools

Apple provides the Xcode toolset used for the development of applications for iOS as well as for theMacintosh platform. The most prominent of these tools are:

• Xcode IDE

• Interface builder

• Instruments

• iOS simulator

The Xcode IDE is the Apple IDE for cocoa programming. It contains many features including versionhandling direct in the IDE.

Interface Builder or IB is the Apple way of creating user interface using drag-and-drop components.

Instruments is a set of tools used to debug and analyze the performance of an application. Amongother things you can view data about the application’s use of network or disc, and also track memoryallocations, which makes it a great tool to get rid of all memory leaks.

14

Page 15: Development with Modern Mobile Technologies

The included iOS simulator makes it possible to test applications without actually having a device. Itis often beneficial to first test applications on simulator during the development phase due to the factthat it’s easily available. The simulator also makes it possible to test on all types of iOS mobile devicesincluding the old iPhone models and the new, retina displayed, iPhone 4 as well as the iPad.

The drawback of testing on the iOS simulator is that does not simulate hardware perfectly. The GPS inthe iPhone can be simulated using the computers wifi to lookup position - if it cannot resolve a positionis defaults to Apple headquarters at 1 infinity loop. For the same reasons using camera does not workeither. Instead it just display a photo library. The size of the simulator on the computer screen mightalso deceive developers that the components in the interface are big enough but is too small on an actualdevice.

3.2.5 Limitations of the iOS platform

Apple requires quite a bit from developers before they can actually start developing.

• An Intel based Mac running Snow Leopard [5]

• An Apple developer account

Having a free apple developer account gives you the possibility to download the xcode toolset andeverything that includes. So you can develop applications with a free account, but you can not testthem on an actual device nor can you distribute them on the Appstore. This is restricted to payingdevelopers.

3.3 Web Frameworks

There are a number of different frameworks available to ease development of web applications. Some aremore focused on rendering pages server side, like a normal webpage, while others are built using frontend languages such as JavaScript to provide a more native feeling using touch events. Due to increasingperformance of the JavaScript engines in both Android and iOS there’s an growing amount of the latter.

3.3.1 jQuery Mobile and jQTouch

jQuery Mobile and jQTouch are both mobile frameworks based on jQuery, a well used and tested cross-browser framework for javascript programming [36],[28],[35]. They’re quite similar but jQuery Mobile ismore of a generic mobile framework than jQTouch which is more focused on the iOS, it’s even shippedwith an iOS lookalike theme.

Some examples of web applications are,

• Stanford University, released a jQTouch based site for users of Android and iPhone besides theirnative app.

• The Swedish Skatteverket, used jQuery Mobile in their mobile application for tax registration 2011.This can easily be spotted from their advertisement since they’re using the default jQuery Mobiletheme.

• The Artspot created a web based multimedia app for tours at art museums using jQTouch calledHoppr[12]. It features audio recordings during the tour and support offline storage using HTML5.

A jQTouch page has the following structure,

• div with id for identifying the page

– div with class toolbar for the header of the page

∗ <h1> tag for title

∗ <a> tag with class button for a button in the header

– divs with class info for text area or lists – ul

15

Page 16: Development with Modern Mobile Technologies

∗ paragraphs, p, for text areas or li for list elements

Elements are enhanced by using key classes specified by the framework. Besides these basic structure,elements can be enhanced with icons, animations and transitions. Using JavaScript, features can beadded using event listeners that react while the users navigates the page.

A simple jQTouch page can be constructed like this:

<html>

<head>

....

<style type="text/css" media="screen">@import "jqtouch/jqtouch.css";</style>

<style type="text/css" media="screen">@import "jqtouch/themes/apple/theme.css";</style>

<script src="jqtouch/jqtouch.js" type="application/x-javascript" charset="utf-8"></script>

....

</head>

<body>

<div id="home" class="current">

<div class="toolbar">

<h1>jQTouch</h1>

<a class="button slideup" id="overlay" href="#overlay">Overlay</a>

</div>

<ul class="rounded">

<li class="arrow"><a href="#page-1">Page 1</a></li>

<li class="arrow"><a href="#page-2">Page 2</a></li>

<li class="arrow"><a href="#page-3">Page 3</a></li>

</ul>

</div>

</body>

</html>

16

Page 17: Development with Modern Mobile Technologies

4 Methodology

Our methodology consists of two parts. The first is to produce criteria to base our evaluation on – thesecond is to actually evaluate the three different mobile technologies based on our previously producedcriteria.

4.1 Criteria

To produce criteria for evaluation we do an analysis of popular applications. We chose to look intowhat features were available in the top 50 free applications on the iOS app store. These applicationswere selected not only because they were available for free but also for the fact that they are a goodrepresentation of applications users will download.

4.1.1 Applications

After composing the list of top 50 free applications (see attachment 10.1) along with their category weremove applications from the games category since they are often a completely different type – whichoften focuses more on graphics – and we want to focus on the simple, easy to make, application.

From the filtered list we went through all applications and analyzed them for the following criteria:

1. Internet Connectivity

We examined if the application performed any information exchange with a server. Examplesof information exchange are fetching articles, products, or song lists. It can also be pushinginformation to the server, for example the Facebook application is used to both fetch status updatesas well as pushing your own statuses and messages.

2. Local Storage

For this criteria we checked if the application saved any data during runs. It seemed applicationsoften used this for two distinct types of features. Either for saving passwords and other userinformation, or for saving larger types of data - like search history, bookmarks or in cases likeSpotify - songs.

3. Camera

This criteria was pretty straight forward - we mainly checked if the application used the camerabuilt into the device.

4. GPS

Just a check if positioning from the GPS was used at all.

The results of the analysis are shown in Table - 2.

4.1.2 Evaluation of criteria

From Figure–9 we acknowledge that the main features of most applications are internet connectivity andlocal storage. And during our research we found that these two criteria account for the most functionalityto an app. Although using GPS location makes an application a lot more user friendly - for instance inweather apps which find your position automatically - we feel it is a secondary to actually being ableto save recent searches, login information, or bookmarks. Therefore we decided to focus on internetconnectivity and local storage as the two main features in an application.

While these two criteria explains the usage of an application to a great length we still need criteriato evaluate the actual development process - and not just how the different technologies deal with thefeatures of an application. Therefor we decided to add two more criteria concerning the actual developingphase - Interface creation and deployment of the application.

17

Page 18: Development with Modern Mobile Technologies

With our now four criteria we have a solid base to evaluate our selected technologies, but the criteria arestill a bit rough, so we decide to split them into a few questions to have in mind while doing the actualevaluation.

1. Interface

• Creating a simple, native UI

• Creating a custom designed UI

• Creating custom UI components

• Using third party components

2. Internet Connectivity

• Creating a connection to a server

• Parsing information from a server - XML, JSON or similar

3. Local storage

• Database Storage

• Store simple information - e.g. Login information

• Storing Blobs - Binary Large Objects.

4. Deployment

App Name Category Connectivity Local Storage Camera GpsExpressen News Yes Yes No NoSMHI Weather Yes Yes No YesGrillfest Lifestyle No Yes No NoMitt Telia Utilities Yes Yes No YesMyggavstotaren Healthcare & fitness No No No NoOld Photo PRO Photography No No Yes NoTalking Tom Cat 2 Entertainment Yes No No NoVeckoappen Utilities No No No Noklart.se Weather Yes Yes No YesHeyTell Social Networking Yes Yes No YesFacebook Social Networking Yes Yes Yes YesSpotify Music Yes Yes No NoTV4 Play Entertainment Yes No No NoYr.no Weather Yes Yes No YesInstagram Photography Yes Yes Yes YesAchmeds Soundboard Entertainment No No No NoRunKeeper Healthcare & fitness Yes Yes No YesBlocket Lifestyle Yes Yes Yes YesAftonbladet News Yes No No NoVardagsmaten.se Lifestyle Yes Yes No NoSwedbank Finance Yes No No YesHemnet Lifestyle Yes Yes Yes YesViber Social Networking Yes Yes Yes NoSkype Social Networking Yes Yes Yes NoSveriges Radio Play News Yes Yes No NoTv.nu Utilities Yes Yes No Nohitta.se Navigation Yes No No YesHitta min iPhone Utilities Yes No No Yeseniro.se Navigation Yes No No YesBirthday.se Utilities Yes Yes No No

Table 2: Filtered top 50 free applications with common features analyzed

18

Page 19: Development with Modern Mobile Technologies

• Requirements for deploying an application

• Deploying for usage on developer phones

• Deploying for closed group usage - e.g. company

• Deploying for large scale distribution

4.2 Toolset

All evaluation is done using Mac OSX. For Android development Eclipse with ADT 10.0 is used andSDK Tools revision 9 with Android 2.3.3 as target for deployment. A Google Nexus One is used to testthe application. For iOS, we’ve used Xcode 4 with iOS 4.3 as target and an iPhone 3GS as device. Bothdevices were also used to test the web application. The backend uses Django 1.3 and runs on a Ubuntu10.10 virtual machine with an Apache web server and SQLite database.

Figure 9: Basic components of most popular applications

19

Page 20: Development with Modern Mobile Technologies

20

Page 21: Development with Modern Mobile Technologies

5 Procedure

5.1 Backend

KTH has some public APIs for interfacing some of it’s databases. Due to limitations and incompatibilitieswe’ve decided to create a custom backend to ease development.

5.1.1 Courses

To get a list of all courses at KTH we first fetched all departments from http://www.kth.se/student/

kurser/kurser-per-avdelning. Using these, we could fetch all courses for that department by visit-ing http://www.kth.se/student/kurser/avdelning/<ShortnameOfDepartment>/kurser. We wrotea simple python parser which fills the database with relevant course info using regular expressions. TheDjango backend then exposes all courses with a JSON-feed, an array of dictionaries, representing allcourses.

5.2 Android

5.2.1 Interface

Android user interface can be constructed either by using the tools included with the Eclipse plugin,writing the XML code by hand or by declaring the components within the application code. It’s oftensimpler to write the XML code by yourself since the UI tools produces lots of unnecessary code makingit unreadable and does not always get it right.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent" android:layout_height="fill_parent"

android:orientation="vertical">

<TextView android:id="@+id/firstLine" android:text="First Line"

android:layout_height="wrap_content" android:layout_width="wrap_content" />

<TextView android:id="@+id/secondLine" android:text="Second Line"

android:layout_height="wrap_content" android:layout_width="wrap_content" />

</LinearLayout>

The xmlns:android declares the use of the android extensions for XML such as layout and data attributes.Using android:id we make it possible to get a reference to the component within the application usingthe method findViewById. It’s also possible to create own attributes for custom components.

Theming an application is possible by either declaring properties on a component basis or by creating atheme per activity or the whole application. A theme can override the looks of widgets and componentsby overloading their default properties.

In our KTH app we’ve mostly utilized ListView to display data. A ListView is a view componentdisplaying rows from an adapter that contains the data. There are a few simple adapters such asdisplaying an array of strings or using a database cursor but the developer is free to implement his own.The adapter contains a getView which returns the row for a given index. To increase performance, oneparameter is a possible previous shown view which can be reused to avoid garbage collection and creatinga new object.

5.2.2 Internet Connectivity

Since Android is based on Java, the simplest and most common way to access network data is by usingApache’s HttpClient library. The library is included within Android so there is no need to add any extradependencies. To comply with the maximum execution time in the UI thread, data is usually fetchedinside an AsyncTask.

21

Page 22: Development with Modern Mobile Technologies

Android is bundled with a JSON library which means that no extra code has to be added for parsing. Toparse XML, developers can choose from a variety of parser methods including SAX, DOM and XMLPull.Parsing is a huge difference, to parse JSON data only a few lines of code is needed:

String jsonStr = new String("[...]");

JSONArray jsonArr = new JSONArray(jsonStr);

JSONObject jsonObject = jsonArr.getJSONObject(0);

String str = jsonObject.getString("str");

5.2.3 Local Storage

Many applications utilizes storage devices such as memory cards for caching and saving of data. Androidalso includes two specific types of data storage, Shared Preferences for settings and Content Provider forwrapping a database or similar data source.

Shared Preferences acts as a simple key-value storage encrypted inside a directory for each applicationwhich utilize it. It’s also possible to define a list of preferences in XML and create a settings screen withthem using PreferenceActivity.

Content Provider is an abstraction for supplying data and uses a RESTful interface for accessing andmodifying data. It also provides possibilities for cross application exchange of data. Often, the provideris backed by a SQLite database containing all data.

To provide all data in our KTH app, we opted for a locally stored database to increase speed. When theapp is first started, the SQLite database is initialized and tables are created. After a successful databasecreation, a service is created which spawns a thread that fetches all KTH courses from our backend.During this the app displays a loading overlay to avoid unintentional user interactions.

5.2.4 Deployment

By using the SDK tools, the developer can generate an APK which can then be distributed. Besidesusing the generated debug certificate the developer can generate a certificate to signing the package withbefore sending it out to testers. This is also needed for Android Market distribution. When uploadingyour application to Google’s Market, it’s available instantaneously for endusers.

To use Google services such as Maps, the developer’s key needs to be paired with an extra API key forthe service [24].

Since we haven’t deployed our application any wider than our testing device, we’ve only utilized thedebug key.

5.3 iOS

5.3.1 Interface

The interface in iOS can be done either by writing code or by using the tools mentioned earlier - Interfacebuilder (IB). When using Interface Builder you drag and drop UI components. To be able to access thecomponents from the code - for instance change text of a label during execution - you have to declare anoutlet in the header file for that UIViewController by declaring a variable as a IBOutlet. When thisis done the outlet is accessible in the IB and by dragging you connect the outlet to the specified view.

Developers are not forced to use the Interface Builder. Instead of dragging and dropping views one canjust declare a view in the view controller, set a frame, and add as a subview to the UIViewController’sview.

So, to create a simple - native - user interface is an easy task as the iOS provides many standard viewsthat doesn’t require any modification. Basically you just provide the data.

If you want to customize the UI you can do it on many levels. The standard views provided often havedifferent options such as text-alignment, background color or borders. But if you want more functionality

22

Page 23: Development with Modern Mobile Technologies

you can either subclass the component in question or subclass UIView and then make your own versionof that component.

If you want to create a custom component implementing a new feature - you have to subclass a UIViewor another subclass of it depending on what feature you want to implement. An example of a popularcustom component is the ipod-like scroll wheel implemented by Tapbots in their app ConvertBot [26].To create a component like this you need to catch the touch and drag events of the wheel and animatethe rotation.

5.3.2 Internet Connectivity

iOS provides several methods of fetching content from the web. The basic method is to make a request,save the data and convert or parse it into whatever datatype you want. This can look something likethis:

NSString *url = [NSString stringWithFormat:@"..."];

NSError *error;

NSURLRequest *request = [NSURLRequest requestWithURL:

[NSURL URLWithString:url]];

NSURLResponse *response;

NSData *result = [NSURLConnection sendSynchronousRequest:request

returningResponse:&response error:&error];

NSString *string = [[NSString alloc] initWithData:result

encoding:NSUTF8StringEncoding];

This kind of request can be shortened into a convenience method.

NSString *url = [NSString stringWithFormat@"..."];

NSError *error;

NSString *string = [NSString stringWithContentsOfURL:

[NSURL URLWithString:url] encoding:NSUTF8StringEncoding error:&error];

The problem with this method of fetching data is that it is synchronous. This means that the fetchingis executed sequentially - hence UI and everything else has to wait which makes the application freeze.Therefor we need to fetch data asynchronously. The most basic method fetching asynchronously is againto create an request.

NSString *url = [NSString stringWithFormat@"..."];

NSError *error;

NSURLRequest *request = [NSURLRequest requestWithURL:

[NSURL URLWithString:url]];

NSURLConnection *connection = [[NSURLConnection alloc]

initWithRequest:request delegate:self startImmediately:YES];

This time though you also need to implement the following functions to define what will happen whenfor instance more data is received or when the download finishes.

- (void) connection:(NSURLConnection *)connection

didReceiveResponse:(NSURLResponse *)response

- (void) connection:(NSURLConnection *)connection

didReceiveData:(NSData *)data

- (void) connection:(NSURLConnection *)connection

didFailWithError:(NSError *)error

- (void) connectionDidFinishLoading:(NSURLConnection *)connection

This on the other hand is a completely viable solution - as the fetching is executed on a separate thread.Another way to fetch data asynchronously - and a way we prefer to use is to create a thread manuallywhich fetches the data synchronously using the convenience method mentioned above.

NSDictionary *args = [[NSDictionary alloc] initWithObjectsAndKeys: ... ];

23

Page 24: Development with Modern Mobile Technologies

NSThread* myThread = [[NSThread alloc] initWithTarget:self

selector:@selector(asychMethod:) object:args];

[myThread start];

Which starts a thread to execute the method asychMethod with the optional arguments described in theargs dictionary. The started method can contain something simple like this:

- (void)loadCourse:(NSDictionary *)args{

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

NSString *url = [NSString stringWithFormat@"..."];

NSError *error;

NSString *string = [NSString stringWithContentsOfURL:

[NSURL URLWithString:url] encoding:NSUTF8StringEncoding error:&error];

....

[pool release];

}

When the data is fetched we have a string consisting of JSON data. To be able to use it we need to parseit into a dictionary. Unfortunately the iPhone has no built in JSON parser, but there are several opensource projects solving the problem. We used a popular framework, SBJson, which adds an method tothe NSString class which makes a dictionary or list depending on the containing JSON [13].

NSDictionary *data = [string JSONValue];

5.3.3 Local Storage

The Apple way of storing data inside the app is using their framework called Core Data. This is anabstraction upon a database - often SQLite [4].

To store data you have to build a a structure of NSEntities. NSEntities can have attributes, corre-sponding to values, and relationships, which describes a relation between two entities. To fetch datayou create a request for a given NSEntities. You can filter or search by adding an NSPredicate to therequest, or sort by adding an NSSortDescriptor.

For simple key-value storage, for example a preference you can use the simpler NSUserDefaults.

For password storing Apple supplies a keychain feature allowing for safe storage [8].

5.3.4 Deployment

To deploy an application on App Store you need to have a developer account. You can get a developeraccount for free, which allows you to develop applications, but not to actually release them or even testthem on your own device. An account cost from $99/year [6].

To actually deploy it after you’ve gotten you account is not actually an easy task. Apple puts a lot ofcare into what application goes on to the App Store so a screening process is used, and many applicationsare denied.

To test an application you need to create certificates to verify that you are indeed the developer. Thiscertificate is also connected to a provisioning profile containing the application identifier. The provision-ing profile also includes which devices are allowed for testing. So to test an application within a groupof people you have to add every device id to the provisioning profile.

There are some ways to make testing easier. For instance a third party service called TestFlight allowsfor easy deployment where you can invite testers by sending an invitation to their device. TestFlightuses Apple’s Enterprise distribution system [40].

24

Page 25: Development with Modern Mobile Technologies

5.4 Web Application

To evaluate the usefulness of web based applications we created a simple jQTouch website [28]. Forsimplicity, we opted to use pages constructed in the backend instead of building them using JavaScript.

5.4.1 Interface

Web applications are built in using standard web components such as HTML, CSS and JavaScript. Mostframeworks includes some default theme to look more like a native application. To change the looks of theapplication, it’s usually enough to customize the CSS with colors, fonts and images. For more extensivecustomization, JavaScript is often required to change or enhance the behavior of the application.

We thought about changing the colors for a more KTH-like theme but opted to use the Apple theme fora more native look.

5.4.2 Internet Connectivity

Since web applications are often already executed from a web server, Internet connectivity is alreadyrequired. To request data while the application is running, AJAX is the most common way to interactwith the backend. Another way is by creating iframes that invokes the pages in the backend.

jQTouch utilizes AJAX for loading data or pages rendered in the backend.

5.4.3 Local Storage

Using HTML5 it is possible to create simple database storage inside the browser. It’s of course alsopossible to utilize the backend database. Another means of storage are by using cookies or session data.

For ”My Course”, we’ve saved the users selected courses using HTML5 local storage.

5.4.4 Deployment

A major advantage with web applications are that the developer has 100% control of the applicationsince your hosting it on your web server. It’s also possible to deploy the web application using somekind of native wrapper such as a WebView for Android or UIWebView for iOS. PhoneGap is a projectcreated specifically for this purpose, it supports native plugins for the web application [34].

25

Page 26: Development with Modern Mobile Technologies

26

Page 27: Development with Modern Mobile Technologies

6 Results

6.1 Backend

The backend consists of a simple Django based application with a SQLite database containing all courses.Through a simple RESTful interface, a client can request a variety of different information. All info exceptfor the courses list is fetched and parsed from the KTH homepage when a request occurs. To cutdownexecution time, results should be cached using simple HTTP Caching.

6.2 Android

The Android application consists of a content provider and three activities.

Content Provider

The content provider acts as local storage for the courses list fetched from the backend. We interfaced itby declaring it as a search provider which allows us to search for courses both inside our KTH applicationand from the global search application. To enable this functionality, some additional meta columns areadded when querying the database.

Main Activity

The main activity allows the user to trigger a search action for courses. The search uses the database tolist all courses and allows the user to filter and pick a course to view, figure 10 – 11.

Course Activity

The course activity displays the chosen course and fetches all info from KTH’s ”Course and programmedirectory”, figure 12.

Schedule Activity

The schedule activity uses a ListView to display the current course schedule. The schedule data is fetchedfrom KTH’s API, figure 13.

6.3 iOS

The iOS application fetches data from the server and KTH APIs much like in the Android version. Whencourses are loaded they are saved in a local database from there they are fetched when they are needed.

The application contain four views shown in Figures 14 – 17. All four views are based on the nativeUITableView with a UITableViewController supplying the data fetched from the database. The searchis implemented by adding a UISearchDisplayController to the UITableViewController. This pro-vides an additional UITableView for displaying the results as well as a search bar and a keyboard forinput searches. The UISearchDisplayController provides a method for which action to take whensearch query changes. In our case we searched through our database and filter our courses on the queryin question - the result was displayed in the UISearchDisplayController’s UITableView

The navigation between views were automatically handled by the built in UINavigationController

which handles pushing and popping of views with a smart and intuitive UI.

27

Page 28: Development with Modern Mobile Technologies

6.4 Web Application

We built a simple jQTouch application where the user can add his courses and get info and schedule foreach course. Pages are rendered in a simple backend from the JSON results to HTML. jQTouch providesa lookalike Apple theme which we’ve used to get a native feeling. It also contains CSS transitions betweenpages. Figure 18 and 19 displays the application.

Figure 10: Android - Search Figure 11: Android - Filtered Search

28

Page 29: Development with Modern Mobile Technologies

Figure 12: Android - Course Info Figure 13: Android - Schedule

29

Page 30: Development with Modern Mobile Technologies

Figure 14: iOS - Search Figure 15: iOS - Filtered Search

30

Page 31: Development with Modern Mobile Technologies

Figure 16: iOS - Course Info Figure 17: iOS - Schedule

31

Page 32: Development with Modern Mobile Technologies

Figure 18: jQTouch - My Courses Figure 19: jQTouch - Course Info

32

Page 33: Development with Modern Mobile Technologies

7 Analysis

7.1 Interface

The interface for the Android application were built with hand coded XML while the iOS were mainlyconstructed with Interface Builder which generates the XML. The Xcode tools for building interfacesare much more competent and evolved than their’s Android counterpart. Work is underway to improvethem but for now, they’re subpar compared to Apple’s suite of tools.

7.2 Third Party Libraries

When we constructed the schedule view for each applications we searched for a custom week calendarview. For iOS there were a few quite decent looking projects which would suffice but we couldn’t findany good alternatives for the Android platform. We tried to customize the native Calendar applicationfor Android but many parts of it are proprietary libraries supplied by Google which meant we couldn’tfully get it working as we wanted in the timespan of this project. This lead to an agenda style view forthe Android version.

This is a common situation, there are lots and lots of Open Source projects with custom views andcontrollers for iOS but not quite as many for Android. An interesting fact since Android is supposedto be about openness and diversity. Our guess for this predicament is that the iPhone’s popularity andslightly longer lifespan has lead to more developers contributing.

Sites such as Cocoa Controls provide an excellent start when searching for custom views and controllersfor an iOS application [38]. We couldn’t find anything similar to the Android platform so instead we hadto search and evaluate possible candidates by ourself. Github and Google Code provides free hostingfor Open Source projects and many Android and iOS developers choose to put their creations for publicviewing [23],[25]. Github is now the most popular site for hosting code projects judging by the numberof commits [20].

7.3 Internet Connectivity

Both Android and iOS includes simple ways for initiating requests using HTTP.

Threading requests to avoid blocking the UI thread is encouraged for both platforms. iOS NSURLConnection

is even asynchronous by default. Android instead enforces threading by displaying an error when theapplication is not responding to input for 5 seconds.

iOS lacks a default library for JSON parsing but it’s not difficult to add a third party library to fill thevoid. The XML support is about the same on both platforms.

7.4 Local Storage

Both platforms includes some kind of local database wrapped with an abstraction layer, Content Providerin the case of Android and Core Data for iOS. This allows for managed queries to get data instead ofhaving to manually create all SQL queries.

Caching binary files are also possible with both platforms. This is usually recommended when usinglarge files from the web or similar.

7.5 Deployment

Deploying an Android application is really simple. As mentioned in the introduction, the source codeis compiled into Dalvik bytecode and packaged into an APK together with assets and resources. Thedeveloper then signs the package with his key and it’s ready for usage. He then either distributes thepackage by himself, as we’ve done during the project, or uploads it to any of the distribution networks such

33

Page 34: Development with Modern Mobile Technologies

as Android Market. This worked flawless and no problems were encountered installing our applicationon different phones.

iOS is definitely more troublesome. The reviewing process before the application is published in the AppStore can be a hassle with a tight deadline.

7.6 Web Applications

Web applications provide a quick and easy way to fulfill the need of mobile users. To instantaneously beable to push updates and fixes is a great benefit. Since not all browsers confirm to the HTML standards,there might be platform specific errors or anomalies which has to be fixed.

34

Page 35: Development with Modern Mobile Technologies

8 Conclusions

To make an easy application for smartphones it is a valid choice to make a web application instead ofmaking native applications. The benefits are many. You only have to make one app and not one foreach platform you want to cover. If you already have a backend you need to access from the applicationanyway, making a web application does not have to be a lot of extra work, since deployment is free inboth the time and monetary sense. Comparing it to the Apple way of deploying where you need to payto even be allowed to upload your application - then you need to wait for application to be accepted byApple. If you are rejected the procedure will begin all over again.

The benefits of making native applications are better performance and more native support. It is easierto access hardware in the application. There is an added bonus to actually having an application onapp stores and that is publicity. When an application becomes popular it may reach a point where itpromotes itself. In a web application this can be solved by creating an application containing a web viewwhich in turn access the web application, or by using frameworks such as PhoneGap.

35

Page 36: Development with Modern Mobile Technologies

36

Page 37: Development with Modern Mobile Technologies

9 Bibliography

[1] Frank Ableson and Robi Sen. Android in Action. Manning Publications, 2011. isbn: 9781935182726.[2] Appcelerator. Appcelerator Titanium. url: http : / / www . appcelerator . com/ (visited on

06/09/2011).[3] Apple. Apple’s App Store Downloads Top 10 Billion. url: https://www.apple.com/pr/library/

2011/01/22appstore.html (visited on 06/09/2011).[4] Apple. Core Data. url: http://developer.apple.com/library/mac/#documentation/Cocoa/

Conceptual/CoreData/cdProgrammingGuide.html (visited on 06/09/2011).[5] Apple. iOS Dev Center. url: http://developer.apple.com/support/ios/ios-dev-center.

html (visited on 06/09/2011).[6] Apple. iOS developer accounts. url: http://developer.apple.com/programs/ios/ (visited on

06/09/2011).[7] Apple. ios MVC. url: http : / / developer . apple . com / library / ios / #documentation /

Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html#

//apple_ref/doc/uid/TP40002974-CH6-SW1 (visited on 06/09/2011).[8] Apple. Keychain in iOS. url: http://developer.apple.com/library/ios/#documentation/

Security/Conceptual/keychainServConcepts/iPhoneTasks/iPhoneTasks.html%23//apple_

ref/doc/uid/TP30000897-CH208-SW1 (visited on 06/09/2011).[9] Apple. Memory Management Rules. url: http : / / developer . apple . com / library / mac /

#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html%23//apple_ref/

doc/uid/20000994-BAJHFBGH (visited on 06/09/2011).[10] Apple. UITableView. url: http://developer.apple.com/library/ios/#documentation/

UIKit/Reference/UITableView_Class/Reference/Reference.html (visited on 06/09/2011).[11] Apple. UIView. url: http://developer.apple.com/library/ios/#documentation/UIKit/

Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/cl/UIView (visited on06/09/2011).

[12] The Artspot. Hoppr. url: http://www.hoppr.eu/ (visited on 06/09/2011).[13] Stig Brautaset. JSON Framework. url: http://stig.github.com/json-framework/ (visited on

06/09/2011).[14] Ed Burnette. Hello, Android: Introducing Google’s Mobile Development Platform (Pragmatic Pro-

grammers). Pragmatic Bookshelf, 2010. isbn: 9781934356562.[15] D. Crockford. RFC 4627 - JSON. url: http://tools.ietf.org/html/rfc4627 (visited on

06/09/2011).[16] Android Developers. ADT Plugin for Eclipse. url: http://developer.android.com/sdk/

eclipse-adt.html (visited on 06/09/2011).[17] Android Developers. Android Architecture. url: http : / / developer . android . com / guide /

basics/what-is-android.html (visited on 06/09/2011).[18] Android Developers. Platform Versions. url: http://developer.android.com/resources/

dashboard/platform-versions.html (visited on 06/09/2011).[19] Android Developers. Screen Sizes and Densities. url: http : / / developer . android . com /

resources/dashboard/screens.html (visited on 06/09/2011).[20] Klint Finley. Github Has Surpassed Sourceforge and Google Code in Popularity. url: https://

www.readwriteweb.com/hack/2011/06/github-has-passed-sourceforge.php (visited on06/09/2011).

[21] Flickr. Flickr: Camera Finder. url: http://www.flickr.com/cameras/ (visited on 06/09/2011).[22] Gartner. Gartner Says 428 Million Mobile Communication Devices Sold Worldwide in First Quar-

ter 2011, a 19 Percent Increase Year-on-Year. url: http://www.gartner.com/it/page.jsp?id=1689814 (visited on 06/09/2011).

[23] GitHub. GitHub. url: http://github.com/ (visited on 06/09/2011).[24] Google. Android Maps API Key Signup. url: https://code.google.com/android/maps-api-

signup.html (visited on 06/09/2011).[25] Google. Google Project Hosting. url: http : / / code . google . com / hosting/ (visited on

06/09/2011).

37

Page 38: Development with Modern Mobile Technologies

[26] iTunes. Apple. url: http : / / itunes . apple . com / us / app / id308928075 ? mt = 8 (visited on06/09/2011).

[27] json.org. JSON. url: http://json.org/ (visited on 06/09/2011).[28] David Kaneda. jQTouch. url: http://jqtouch.com/ (visited on 06/09/2011).[29] Wei-Meng Lee. Beginning iPhone SDK Programming with Objective-C (Wrox Programmer to Pro-

grammer). Wrox, 2010. isbn: 0470500972.[30] MoSync. MoSync. (Visited on. 06/09/2011).[31] Novell. MonoDroid. url: http://mono-android.net/ (visited on 06/09/2011).[32] Novell. MonoTouch. url: http://monotouch.net/ (visited on 06/09/2011).[33] Randall Reynolds Clemente Izurieta Nurzhan Nurseitov Michael Paulson. “Comparison of JSON

and XML Data Interchange Formats: A Case Study”. MA thesis. Montana State University, url:http://www.cs.montana.edu/izurieta/pubs/caine2009.pdf (visited on 06/09/2011).

[34] PhoneGap. PhoneGap. url: http://phonegap.com/ (visited on 06/09/2011).[35] The jQuery Project. jQuery. url: http://jquery.com/ (visited on 06/09/2011).[36] The jQuery Project. jQuery Mobile. url: http://jquerymobile.com/ (visited on 06/09/2011).[37] Andy Rubin. I think I’m having a Gene Amdahl moment. url: http://android-developers.

blogspot . com / 2011 / 04 / i - think - im - having - gene - amdahl - moment . html (visited on06/09/2011).

[38] Structlab. Cocoa Controls. url: http://cocoacontrols.com/ (visited on 06/09/2011).[39] Sun. Java BluePrints - J2EE Patterns. url: http://java.sun.com/blueprints/patterns/MVC-

detailed.html (visited on 06/09/2011).[40] Testflightapp.com. TestFlight. url: https://testflightapp.com/ (visited on 06/09/2011).[41] W3C. HTML5. url: http://dev.w3.org/html5/spec/Overview.html (visited on 06/09/2011).[42] Xamarin. Xamarin. url: http://www.xamarin.com/ (visited on 06/09/2011).

38

Page 39: Development with Modern Mobile Technologies

10 Attachments

10.1 iOS Top 50 Free Applications

App Name CategoryExpressen NewsSMHI WeatherAir penguin lite Games4 in a row - deluxe GamesZentomino GamesHit Tennis 2 GamesGrillfest LifestylePig shot GamesMitt Telia UtilitiesMyggavstotaren Healthcare & fitnessOld Photo PRO PhotographyTalking Tom Cat 2 EntertainmentVeckoappen UtilitiesPaper Glider Crazy Copter Gamesklart.se WeatherHeyTell Social NetworkingFacebook Social NetworkingAngry Pig Daddy GamesSpotify MusicTV4 Play EntertainmentYr.no WeatherBloody knuckles Free GamesInstagram PhotographyMinesweeper Q GamesBubble Shooter adventures GamesAchmeds Soundboard EntertainmentRunKeeper Healthcare & fitnessJelly Drop GamesBlocket LifestyleAftonbladet NewsVardagsmaten.se LifestyleSwedbank FinanceWordCollapse GamesHemnet LifestyleViber Social NetworkingSkype Social NetworkingFragger GamesMahjong Elements GamesSveriges Radio Play NewsCity Friends GamesTv.nu Utilitieshitta.se NavigationAngry Birds Free GamesTap the frog GamesHitta min iPhone Utilitieseniro.se NavigationGelato Mania GamesBirthday.se UtilitiesBaby Adopter GamesFreeAppKing Games

39