Chapter 6. Mobile platforms

This 4.8-ounce sliver of glass and aluminum is an explosive device that has forever changed the mobile-phone business, wresting power from carriers and giving it to manufacturers, developers, and consumers.

“The Untold Story: How the iPhone Blew Up the Wireless Industry,” Wired Magazine, January 9, 2008

This chapter covers

  • Latest trends in mobile development
  • Details of major mobile development platforms with extensive comparisons
  • Mobile development frameworks
  • Testing your mobile applications

With major disruptions from Apple and Google in the form of the iPhone, iPad, and Android, the mobile development landscape has forever changed from a closed API, carrier-centric model to an open API, device-manufacturer- and software-developer-centric model. This major shift represents a huge opportunity for LBS application developers as well, because now it’s possible to develop fully featured LBS applications and release them to consumers directly—at least most of the time.

But still, mobile development is fragmented between a number of different mobile operating platforms, each supporting a different range of functionality and applications. Because there are so many options, it’s important to understand each mobile platform along with market trends when planning your LBS application. Also, resources are constrained on a mobile phone, including screen size, memory, CPU, storage, and input method, making it especially important to properly understand and pick from available programming options. Figure 6.1 shows the major smart-phone platforms.

Figure 6.1. Major new mobile platforms: iPhone, Android, HP webOS, BlackBerry Storm, and the iPad, which are disrupting the old mobile ecosystem

In this chapter, we’ll look at all major mobile development platforms, from the iPhone and Android to the relatively new MeeGo. We’ll look at the basic development process for each of these platforms to get a high-level understanding of the pros and cons of each platform.

But before starting our analysis, let’s look at how the market is evolving and which platforms are gaining in popularity to try to understand the current trends.

6.1. Mobile phone trends

According to Gartner, Inc., 417 million mobile phones were sold in the third quarter of 2010, an 35% increase from the third quarter of 2009.[1] Nokia continues to lead the mobile phone market, but its share in 2010 dropped to 28.2% from 36.7% in the third quarter of 2009 (see table 6.1). Samsung retains second place and improved its market share; its sales totaled 71.6 million units.

1http://www.gartner.com/it/page.jsp?id=985912

Table 6.1. Worldwide mobile phone sales for the third quarter of 2010

Company

Q3 2010 sales

Q3 2010 share

Nokia 117,461.0 28.2
Samsung 71,671.8 17.2
LG 27,478.7 6.6
Apple 13,484.4 3.2
Research In Motion 11,908.3 2.9
Sony Ericsson 10,346.5 2.5
Motorola 8,961.4 2.1
HTC 6,494.3 1.6
ZTE 6,003.6 1.4
Huawei Technologies 5,478.1 1.3
Others 137,797.6 33
Total 417,085.7 100

Smartphone sales grew 96% from the third quarter last year, and smartphones accounted for 19.3% of overall mobile phone sales in the third quarter of 2010 (see table 6.2).

Table 6.2. Worldwide smartphone sales by operating system for the third quarter of 2010

Company

Q1 2010 sales

Q1 2010 share

Symbian 29,480 36.6
Android 20,500 25.5
iOS 13,484 16.7
Research In Motion 11,908 14.8
Microsoft Windows Mobile 2,247 2.8
Linux 1,697 2.1
Others 1,214.8 1.5
Total 80,532 100

Now let’s look at how the programming options are evolving alongside these trends.

6.2. How programming and distribution options are evolving

Until the iPhone, carriers had all the power. Development took a long time; deployment took longer. Apple has been a major disruptive force in the mobile ecosystem, where carriers used to exert complete control. The high cost of entry to mobile development has been almost completely eliminated. Now with Google’s Android and other disruptive forces, mobile development is possible for anyone with the help of open APIs and open distribution platforms (app stores).

Whereas Java remains the most widespread format for many mobile applications (especially within mobile marketing and mobile gaming), more sophisticated platforms like that of the iPhone are set to become increasingly popular. Android in particular promises to open up the mobile phone operating system like never before and allow full integration between the phone’s features and the applications running on it.

Also, more app stores are opening, altering the mobile application development business landscape significantly. Developers no longer have to go through the carriers, which is the huge change that’s reshaping the industry. They can develop and deploy applications directly to the consumers. (Please see table 6.3 for an overview of all available app stores and chapter 11 for more details on each app store.)

Table 6.3. Mobile app stores (also see chapter 11 for more details)

Name

Established

Apps

Downloads

Platforms

Dev. Share

Fees

GetJar 2004 53,000 600 million Multiple N/A Free
Apple App Store 7/10/2008 75,000 2 billion iOS 70% $99
Android Market 10/22/2008 10,200 Unknown Android 70% $25
Software Store 12/16/2008 5,000 Unknown Palm OS, Windows Mobile 60% Unknown
BlackBerry App World 4/1/2009 2,000 Unknown BlackBerry OS 80% $200
Ovi Store 5/26/2009 Unknown Unknown Symbian 70% €50
App Catalog 6/6/2009 41 160,000 WebOS 70% Free
LG Application Store 7/13/2009 1,400 Unknown Windows Mobile N/A N/A
Samsung Application Store 9/14/2009 Unknown Unknown Java, Symbian, Windows Mobile 70% $1
Windows Marketplace for Mobile 10/6/2009 N/A N/A Windows Mobile 70% $99/year

Now that we’ve reviewed how existing development and distribution platforms are evolving, let’s look at all the available mobile development platforms.

6.3. Java ME

Java Platform, Micro Edition (Java ME—formerly known as Java 2 Platform, Micro Edition, or J2ME) is a Java platform designed for mobile devices and embedded systems, which range from mobile phones to navigation devices and set-top boxes. Figure 6.2 displays the Java ME architecture.

Figure 6.2. The Java ME platform is a subset of the whole Java platform, targeted for mobile devices. (Source: mng.bz/8aLR)

Java ME is a portable solution that provides universal libraries for a wide range of devices. The resulting application can be run on various different devices. But in general applications (including their data) can’t be larger than around 1 MB if they are to run on most phones. They must also be cryptographically signed (such as for the BlackBerry) in order to effectively use many specific APIs such as the file system access API. To smooth the signing process, the industry has formed the Java Verified organization.

 

Tip: Java Verified

Java Verified[2] is the global organization in which members of the worldwide mobile ecosystem are working collaboratively to address Java ME fragmentation. The organization provides testing and resources for helping Java ME developers deliver more high-quality Java ME applications to more devices faster. The Java Verified management board is made up of representatives from LG, Motorola, Nokia, Orange, Samsung, Sony Ericsson, Sun Microsystems, and Vodafone.

2http://javaverified.com

 

Java ME applications can run on the BlackBerry, Symbian, and most Java-capable phones.

Java ME provides access to a mass market. Java ME is a good choice for high-level applications that don’t require platform-specific native libraries. If your Java ME application accesses the native APIs of a mobile platform, such as the graphics hardware on the BlackBerry to display a more responsive user interface, then naturally your app won’t run on Symbian devices. You have to determine whether you can get away with using just the high-level common Java ME classes in your application. If you can, Java ME is a good solution. If not, you’ll have to write slightly different applications for each Java platform you’re targeting.

6.4. Symbian

The Symbian platform is an open source operating system for mobile devices. It was created by merging and integrating software assets contributed by Nokia, NTT DoCoMo, and Sony Ericsson, including Symbian OS, the S60, UIQ, and MOAP(S) user interfaces. Figure 6.3 displays the system architecture for a Symbian-based phone.

Figure 6.3. Symbian as part of the Nokia S60 platform architecture (source: mng.bz/LSKH)

Symbian is the successor to Symbian OS, launched after the founding of the Symbian Foundation in April 2009. Symbian runs on phones that are using S60 (third revision or later) and Sony Ericsson, Samsung, Siemens, and Motorola mobile phones running Symbian UIQ 3.0 or later. (Motorola has recently started moving toward Android and dropping Symbian for future phones.)

The native language of Symbian is C++, although it isn’t a standard implementation. There were multiple platforms based on Symbian OS that provided SDKs for application developers wishing to target Symbian OS devices. Symbian’s flavor of C++ is specialized. Symbian supports multiple runtimes so that you can use whatever programming language feels right for you, such as Python, Java ME, Flash Lite, Ruby, .NET, Web Runtime (WRT) Widgets, and Standard C/C++. Figure 6.3 displays the architecture of the Nokia S60 platform.

Symbian is a powerful platform for general-purpose development. It was designed specifically for mobile devices from the beginning, so it’s real time and multitasking while trying to minimize memory use and maximize performance and battery life.

The Symbian Foundation maintains the code for the open source software platform based on Symbian OS and software assets contributed by Nokia, NTT DoCoMo, and Sony Ericsson, including the S60 and MOAP(S) user interfaces. Portions of the platform’s source code have already been moved to open source, under the Eclipse Public License. When this process is complete, the platform code will be available to all for free. Close to 300 million Symbian OS-based units have been shipped, and Symbian holds more than a 50% market share globally.

When developing a Symbian application, you first have to choose your target platform, such as Sony Ericsson P800, Nokia 3650/7650, or Samsung i458, because Symbian is just the low-level operating system and the middleware. Each phone carries a different UI on top of the base operating system.

There are currently three main GUI systems:

  • Nokia Series 60
  • Nokia Series 80
  • User Interface Quartz (UIQ)

Table 6.4 summarizes the available GUI systems.

Table 6.4. Major GUI systems for Symbian

GUI

Specifics

Phones

Series 60 v1.x + Symbian OS 6.1 Resolution = 176 × 208 Phone keyboard No touch screen Nokia 3650, Nokia 7650, Nokia N-Gage, Siemens SX1, Samsung SGH-D700, Sendo XXX
Series 60 v2.0 + Symbian OS 7.0s Resolution = 176 × 208 Phone keyboard No touch screen Nokia 6600
Series 80 + Symbian OS 6.0 Resolution = 640 × 200 Full keyboard No touch screen Nokia 9210
UIQ v2.0 + Symbian OS 7.0 Resolution = 208 × 320 Optional keyboard Touch screen Sony Ericsson P800, BenQ P30

Series 60 is the most common platform and easiest to start with. After selecting your target platform, you need to pick a development environment. Your options are

  • Visual Studio
  • Metrowerks CodeWarrior
  • Borland C++ Builder
  • Carbide.c++ (based on the Eclipse IDE and now owned by the Symbian Foundation)

Then you download and install the specific SDK from Nokia, Sony Ericsson, or another source to develop your application to that specific target platform.

Symbian has wide distribution and it’s a robust development environment, but the fragmentation in the GUI layers running on top of Symbian may force you to target only a subset of the available Symbian phones out there. For example, if you want to target most of the Symbian phones, you’ll need to develop at least 100 different clients.

Symbian has a steep learning curve for beginners because of its unique flavor of C++ and the complexities of its GUI layers. Also, from a user point of view, the apps might have a clunky feel if they aren’t fully optimized for the specific platform.

Symbian’s wide distribution is a big draw for developers, but you should weigh all the difficulties of developing on the platform against its distribution when picking release platforms for your product. Java ME is a solution that can run acceptably well if your application is not too computer resource and graphics intensive.

Please see section 6.12 for Nokia’s new open source mobile OS: Maemo.

6.4.1. Nokia Ovi Store

The Nokia Ovi Store (figure 6.4) was launched worldwide in May 2009. Here, customers can download mobile games, applications, videos, images, and ringtones to their Nokia devices. Some of the items are free of charge; others can be purchased using a credit card or through operator billing in selected operators.

Figure 6.4. Nokia Ovi Store

Ovi Store offers customers content that’s compatible with their mobile device and relevant to their tastes and location. Customers can share recommendations with their friends, see what they’re downloading, and let them see the items they’re interested in.

For content publishers, Nokia offers a self-service tool to bring their content to the Ovi Store. Supported content types include J2ME, Flash applications, widgets, ringtones, wallpapers, themes, and more for Nokia Series 40 and S60 devices. Nokia offers a 70% revenue share of gross sales, net of refunds and returns, less applicable taxes and, where applicable, fixed operator billing costs. Please see table 6.3 and chapter 11 for more information.

6.5. iPhone and iPad

Apple Inc.’s iPhone and iPad platforms have forever changed the mobile industry. They’re two of the best-selling consumer electronic devices of all time. iPhone is the fastest-selling smartphone ever, and iPad is selling at even a higher rate than the iPhone. The popularity of the devices among developers and consumers created an explosion of over 200,000 applications (as of mid-2010) that captured the attention of consumers around the world. Here are some numbers about the App Store as of May 2010:

  • Total active apps (currently available for download): 199,790
  • Total inactive apps (no longer available for download): 34,352
  • Total apps seen in the US App Store: 234,142
  • Number of active publishers in the US App Store: 39,283

iPhone application development requires using Objective-C, an Apple-specific variant of C, enhanced with object-oriented features of C or C++. Developers familiar with Mac OS X development can make a quick transition to iOS development, whereas other developers will have a steep initial learning curve, mostly because of Objective-C and iOS specifics.

In short, iOS applications are developed using Objective-C, C, or C++ and Cocoa only on a Macintosh computer in Xcode after signing up as a developer with Apple, and the resulting binaries are submitted to the Apple App Store for approval, which takes one to two weeks. Now let’s look at all the components for iPhone and iPad application development:

  • iOS— iOS is the operating system developed by Apple Inc. for the iPhone, iPad, and iPod touch. iOS applications are written in the Objective-C programming language, using the Cocoa application framework on the Mac OS X. iOS has four abstraction layers: the Core OS layer, the Core Services layer, the Media layer, and the Cocoa Touch layer (figure 6.5).
    Figure 6.5. iOS technology layers (source: mng.bz/d3j3)

  • The iPhone SDK— The iPhone SDK[3] (first released in March 2008) contains the code, information, and tools you need to develop, test, run, debug, and tune applications for the iOS.

    3http://developer.apple.com/iphone/

  • Objective-C— Objective-C is a reflective, object-oriented programming language, which adds Smalltalk-style messaging to the C programming language. It has a steep learning curve for beginners.
  • Cocoa Touch— Cocoa Touch is an API for building software programs to run on the iPhone and iPod touch from Apple Inc. Cocoa Touch provides an abstraction layer of the iOS (figure 6.6), which is the operating system for the iPhone and iPod Touch. Cocoa Touch is based on the Cocoa API toolset for building software programs for Mac OS X computers. Tools for developing applications based on Cocoa Touch are included in the iPhone SDK.
    Figure 6.6. Cocoa Touch in the architecture of the iOS (source: mng.bz/ZGY5)

  • Xcode— Xcode is the development environment that hosts the development tools for the iOS. The Xcode tools have been updated to support development for the iOS. In addition to providing the basic editing, compilation, and debugging environment for your code, Xcode also provides the launching point for testing your applications on an iPhone or iPod touch device. Xcode also lets you run applications in the iPhone simulator, a platform that mimics the basic iOS environment on your local Mac computer.
  • The iPhone Developer Program— This program gives you the cryptographic keys to be able to download your code to a real phone. This currently costs $99 for individuals or $299 for companies.

With over 200,000 applications in the Apple App Store, iPhone and iPad application development has taken the world by storm. Many developers made the crossover to iOS development from other platforms, so there’s an extraordinary amount of resources available for beginners in the form of books and also online.

The platform is robust if you can manage to keep the memory use of your application to a minimum. Crashes are very common in applications that run out of memory.

iOS 4 has brought multitasking to iOS development, but before this, one major limitation of the iOS was that applications couldn’t run in the background. Push notifications is a powerful feature to partially alleviate this limitation. You can send a message to a phone even if the user isn’t running your application at the moment. For example, a user can receive an instant message from a friend even if he’s not currently running the instant messaging application. LBS applications can send alerts to users from their friends or from other services.

So far, the biggest issue with iPhone app development has been the App Store approval process, which can be unpredictable and at times inconsistent. Your application can be rejected for reasons you can’t predict, making all of your investment worthless. The other things to watch out for are documented in the terms of use for the developer program. Apple forbids developers to use undocumented features and checks each binary with automated tools against such use. You also can’t compete with Apple directly or try to replace basic features of the iPhone.

In-app purchases are another great feature that minimizes the friction for your users to buy virtual goods inside your application. They just see a charge in their iTunes account, and Apple relays 70% of the purchase amount to you directly.

A repeated criticism from iPhone app developers comes from the difficulty they find in deploying their application to a real iPhone or iPod Touch. Apple, for better or worse, has designed a process involving many hoops that you must jump through, and this has prompted some developers to grumble and others to explore alternative, non-official open tool chains, which don’t require app signing.

If you’d like to get your paid application to some reviewers for free, you can give them promo codes that enable them to download your app from iTunes for free.

Apple also has given developers a way to beta test iPhone applications with up to 100 iPhones. If you want to get your app to some beta testers before your app is accepted in the App Store, then these users have to send you their unique device identifier (UDID). To find your iPhone’s UDID, plug it into your computer and wait until iTunes recognizes it. Select your phone from the Devices list in iTunes and click the Summary tab. To see your UDID, click the word serial number beside the picture of the iPhone. You should see the word identifier and an alphanumeric string—this is your UDID. To copy it, press Command-C on your Mac’s keyboard (or Ctrl-C in Windows).

6.5.1. Restrictions on iOS development tools

Apple has severely restricted the tools you can use to create iPhone, iPod touch, and iPad apps. The infamous iPhone Developer Program License Agreement Section reads as follows:

3.3.1—Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs. Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iOS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited).

This has caused a huge controversy because this has banned Adobe’s Flash-to-iPhone-App converter as well as other third-party development tools. You should be aware of all of Apple’s restrictions and policies before jumping into iPhone/iPad development.

6.5.2. A simple iPhone app

Let’s now look at how to create an iPhone app that finds the current location of the user and displays it. Follow these steps:

  1. Install the latest iPhone SDK.
  2. Open Xcode (make sure you have the latest version).
  3. Go to File > New Project to create a new project of type View-Based Application. Enter a name, such as AroundMyCity.

This will create a project for an application that uses a single view to implement its user interface. Listings 6.1 through 6.4 display the initial source code of the project. The first listing shows the initial AroundMyCityAppDelegate.h code for the view-based application AroundMyCity.

Listing 6.1. Initial AroundMyCityAppDelegate.h code

Here we declare a class derived from UIApplicationDelegate with two member variables for keeping the UIWindow and view controller pointers .

The next listing shows the initial AroundMyCityAppDelegate.m code for the application AroundMyCity.

Listing 6.2. Initial AroundMyCityAppDelegate.m code

This code is the implementation of the AroundMyCityAppDelegate class where the code overrides the applicationDidFinishLaunching function of the parent class. The code provides a specialized deconstructor to be able to serve customized implementations.

The following listing contains the initial AroundMyCityViewController.h code for AroundMyCity.

Listing 6.3. Initial AroundMyCityViewController.h code

Here we declare a class derived from UIViewController to be able to serve a customized implementation of this class.

The next listing shows the initial AroundMyCityViewController.m code for AroundMyCity.

Listing 6.4. Initial AroundMyCityViewController.m code

This is the basic implementation of the AroundMyCityViewController class with functions that will be customized , , , , , . This is mostly generated by the tools and is generally the same for all projects. After this step we’ll start customizing each function to serve the desired functionality, as follows:

  1. Select Project > Set Active SDK > iPhone Simulator 3.0.
  2. Add the Core Location framework to the application. Right-click Frameworks and select Add > Existing Frameworks. Choose CoreLocation.framework.
  3. Choose Import < CoreLocation/CoreLocation.h > in AroundMyCityController.h.
  4. Make the following changes (shown in bold) to the AroundMyCityController class to get the location of the user.

Listings 6.5 and 6.6 are the final source code for the project that’s fully functional.

Listing 6.5. AroundMyCityController.h code with changes to get the current location

Here you see the new core location header files and the new member variable to hold the location manager object . This member variable will keep a pointer to the location manager object that will be used to find the location of the user. The next listing shows the AroundMyCityController.m code with changes to get the current location.

Listing 6.6. AroundMyCityController.m code modified to get the current location

Here are all the changes that enable this class to get the location of the device from the platform. When the view is loaded, the code initializes the location manager and makes the request to get the location. This asynchronous process calls didUpdateTo-Location if it succeeds and didFailWithError if it fails.

After going through all steps, select Run > Debug, and the iPhone simulator will launch and bring up the application.

The viewDidLoad function will be called when the view is loaded. This function will start retrieving the location. The platform will call the application multiple times with increasingly accurate updates, instead of just one call to enable applications, to control battery drain and time-to-fix parameters.

6.5.3. The Apple App Store

After you develop your application, you submit it to the Apple App Store (figure 6.7) for review. Apple usually takes between one and two weeks to accept or reject your application. If your application is accepted, you can list it in the App Store, and Apple will take care of hosting your application binaries for users to download. Apple takes 30% of the application fee if you charge users to download your application. Please see table 6.3 and chapter 11 for more information.

Figure 6.7. aApple App Store

6.6. Android

Android is a mobile operating system running on the Linux kernel. It was initially developed by Google and later the Open Handset Alliance.[4] It allows developers to write managed code in the Java language, controlling the device via Google-developed Java libraries. Figure 6.8 displays the main architecture of the Android operating system.

4http://www.openhandsetalliance.com/

Figure 6.8. Major components of the Android operating system

Here’s a quick summary: Android application development is done in Java using the Android Java libraries,[5] preferably in Eclipse (an open source development environment), and applications can be submitted to the Android Market. There’s no approval process in the Android Market. Submitted applications go live instantly, unlike those for the Apple App Store.

5http://code.google.com/android/download_list.html

Google has created a powerful and robust mobile operating system in the form of Android. The open nature of Android is already disrupting legacy mobile OSs as well as even the iPhone. Many device manufacturers are moving from legacy platforms to Android and releasing new Android phones.

For example, Motorola has famously dropped Symbian and moved to Android to release the Droid phone with Verizon to compete with the iPhone directly. Sony Ericsson is also moving toward Android and away from its existing OSE, Symbian, and Windows Mobile platforms.

With Android 2.0, Google has also released a free navigation application built into the operating system, which disrupts the paid TomTom and Garmin applications, turning navigation into a commodity feature.

Learning Android development is easy, with Java developers making the quickest jump. Android Java libraries are intuitive, and it helps greatly that the platform is open source. You can actually debug within the operating system libraries if necessary to see what the problems are when your code doesn’t work as expected. Here are some major properties of the Android platform:

  • Multitouch on a limited number of Android devices— Curiously, multitouch capabilities have been left out of the Android SDK until recently except for a few phones just coming out, unlike the iPhone. It’s claimed that this feature will be enabled widely in the near future because some developers created multitouch demos on Android phones by hacking the OS.
  • Multitasking— Android supports multitasking, but this requires a bit of explanation. On a Windows desktop, you can freely start, end, and switch between actively running programs. They continue running the same way whether they’re in focus or in the background. In Android, you don’t have to shut down programs because the system will do it for you when it runs low on memory.

Unlike Windows, Android makes a clear distinction between a program that’s doing work (like downloading a file or playing some music) and one that’s sitting around waiting for the user to return. The commonly quoted “Android can run programs in the background” case is the one where the background program is doing work. You can listen to music from any program while doing work in another. For example, you can download a file while reading your email.

The other case, the one where programs are open but just sitting around, is a little harder to define. This is the situation where a program will technically remain running until the system needs memory; then it will be closed without warning. Because of this, it’s up to the individual application developer to create the illusion of smooth multitasking.

What that means is every time an application loses its focus (disappears from the screen in favor of displaying another program on top of it), it effectively has to save its state out to permanent memory. If it doesn’t, then it will be reset when its memory is reclaimed by the system. Because the application has no way of knowing if it will ever regain focus before being closed, the only reasonable solution is to write out the value of every single variable in memory to the permanent storage and then reload all those variables when the application regains focus. Because of this requirement, you can almost say that Android doesn’t really support multitasking between programs but just creates the illusion that it does.

That conclusion in itself is a bit misleading, because Android actually can multitask between programs, but because it requires all good programs to assume that they’re going to be closed whenever focus is lost, it doesn’t really make much difference. The only real advantage it gains is that if the program isn’t closed before it regains focus, then it can save a second or two by not bothering to load in the save state data from permanent storage.

6.6.1. A simple Android app

Now let’s develop a simple Android application that finds the user’s current location. The sample code will access the Location Manager service from the platform and will use it to get the user’s location. The steps to do so follow:

  1. Download and install Eclipse IDE for Java Developers.[6]

    6http://eclipse.org

  2. Install the Android Development Toolkit into Eclipse. This turns Eclipse into an excellent development environment for Android and is highly recommended. For this, choose Help > Install New Software in Eclipse and add https://dl-ssl.google.com/android/eclipse/ as a site. This will show Developer Tools as available. Select this option and install ADT in Eclipse. Now you have Eclipse ready with the Android plug-in.
  3. Install the latest Android SDK from http://developer.android.com.
  4. In Eclipse, choose Window > Preferences and set the location of the Android SDK in the Android tab. This will link the Eclipse environment to the location of the Android SDK.
  5. Create a new Android project in Eclipse by choosing File > New Project > Android and filling in the project name and application name.

You should have the code shown in the following listing at the end of step 5.

Listing 6.7. Autogenerated Android application source code

In this code sample, you see the main activity class for this application and its member function . The customized onCreate function calls the default implementation of the parent class first .

  1. Open the AndroidManifest.xml file to add permissions for this application to access the Location Manager system component. Add this to the file: <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION” />

 

Tip: Getting Permission to Access Location Services on Android

Note that ACCESS_COARSE_LOCATION allows an application to access coarse (for example, Cell ID, Wi-Fi) locations, and ACCESS_FINE_LOCATION allows an application to access fine (for example, GPS) locations.

 

  1. Import the Location and LocationManager classes.
  2. Get the Location Manager from the system and call it to get the current location. Add the source code in bold to the AroundMyCity.java file. The resulting source code should look like the following listing.
Listing 6.8. The Improved AroundMyCity.java that gets the user’s location using GPS

In this code sample, you see the changes needed to get the Location Manager from the platform and get the location of the device from it and update the UI accordingly .

After going through all the steps, click Debug and choose Android Application, and the application will be installed and launched on your USB-connected Android phone.

In the previous listing, the main application class extends the Activity class. When an activity starts, its onCreate function gets called. The code first calls the parent class’s onCreate method. Then it gets the location of the user, creates a new TextView object, sets its text, and sets the content view to the TextView object, which displays the contents of TextView onscreen.

6.6.2. Android Market

Android Market (figure 6.9) is a software application developed by Google for Android devices, which allows users to browse and download applications published by third-party developers. The Android Market was announced on August 28, 2008, and was made available to users on October 22, 2008. Priced application support was added for US users and developers in the United States and United Kingdom in mid-February 2009. All submitted applications go live immediately, unlike those for other app stores. This makes it very easy to release bug fixes. But it’s difficult to get visibility in the Android Market if yours is not one of the featured apps. Please see table 6.3 and chapter 11 for more information.

Figure 6.9. Android Market

6.7. webOS

webOS is a smartphone platform, based on Linux and developed by Palm, which is now part of HP. The Palm Pre smartphone is the first device to launch with webOS, and both were introduced to the public at the Consumer Electronics Show in Las Vegas on January 8, 2009. The Palm Pre and webOS were released on June 6, 2009. The second device to use the operating system is the Palm Pixi. The webOS features significant online social network and Web 2.0 integration. Please see figure 6.10 for an overview of the webOS architecture.

Figure 6.10. WebOS architecture (source: mng.bz/E16W)

webOS’s graphical user interface is designed for use on devices with touch screens. It includes a suite of applications for personal information management and makes use of a number of web technologies such as HTML 5, JavaScript, and CSS. Palm claims that the design around these existing technologies was intended to spare developers from learning a new programming language. The Palm Pre, released on June 6, 2009, is the first device to run this platform.

webOS development is easy to ramp up because it’s based on common and widely known technologies, but the developer still has to learn and become familiar with the overall structure of a webOS application. Every webOS application has a scene component. A scene is a formatted screen for presenting information or a task to the user. Each scene has a view and an assistant. The view determines the layout and appearance of the scene. The assistant determines the behavior. Some scenes also have models, which supply data.

webOS is a true multitasking operating system. Users can switch between running applications. It also supports multitouch capabilities, just like the iPhone.

Palm is struggling to convince developers to use its platform, and its chances of succeeding are unclear at this point, but it’s definitely an innovative platform.

6.7.1. HP App Catalog

The HP App Catalog (figure 6.11) is an online marketplace for applications for Palm mobile devices running webOS but not Palm OS. Initially, applications are supported only on the Palm Pre.

Figure 6.11. HP App Catalog

The App Catalog is similar to Apple’s App Store for the iOS and Google’s Android Marketplace for Android. At the time of the Palm Pre launch, the App Catalog featured 18 applications. Applications have to be signed through the Developer Portal before being submitted to the App Catalog. Please see table 6.3 and chapter 11 for more information.

6.8. BlackBerry OS

BlackBerry OS is the proprietary software platform made by Research In Motion (RIM) for its BlackBerry line of handhelds. BlackBerry OS provides multitasking and makes heavy use of the device’s specialized input devices, particularly the trackball or touchscreen.

BlackBerry OS development for all recent BlackBerry models is done exclusively in Java using Java ME, which is itself a derivative of Java version 1.3 (but not 1.5, which has all the latest features such as generics, enumerations, and so on). Applications have to be cryptographically signed with security keys from RIM before being distributed (through BlackBerry App World or directly). The BlackBerry platform is shown in figure 6.12.

Figure 6.12. BlackBerry architecture (source: mng.bz/1hue)

The BlackBerry platform is based on the CLDC[7] and includes support for MIDP 2.0.[8]

7http://java.sun.com/products/cldc/

8http://java.sun.com/products/midp/

  • CLDC— The Connected Limited Device Configuration (CLDC) defines the base set of application programming interfaces and a virtual machine for resource-constrained devices like mobile phones, pagers, and mainstream personal digital assistants. When coupled with a profile such as the Mobile Information Device Profile (MIDP), it provides a solid Java platform for developing applications to run on devices with limited memory, processing power, and graphical capabilities.
  • MIDP— The Mobile Information Device Profile lets you write downloadable applications and services for network-connectable mobile devices. When combined with the Connected Limited Device Configuration, MIDP is the Java runtime environment for today’s most popular compact mobile information devices, such as cell phones and mainstream PDAs.

The BlackBerry platform also contains a large number of BlackBerry-specific classes. This leaves you with the question of whether to write a BlackBerry application or an MIDP application.

In an MIDP application you’re constrained to use only the APIs exposed by the CLDC and MIDP standards. Your application will run on the BlackBerry and on most mobile phones, but it won’t be able to use any of the BlackBerry’s special features. You can use any MIDP-compatible development tool, such as the Sun Java Wireless Toolkit for CLDC (formerly known as the J2ME Wireless Toolkit), to create your applications.

Most application developers opt to build BlackBerry-specific applications. This means learning the BlackBerry-specific APIs, including new user interface classes, and using the BlackBerry Java Development Environment (JDE)[9] to develop applications. The JDE, which is free to download, works with the standard Java Software Development Kit and provides you with all the tools necessary to create, package, test, and debug BlackBerry applications. You don’t even need a BlackBerry handheld, because the JDE includes a full-featured BlackBerry device simulator. A complete set of documentation is provided that describes all the classes and interfaces available to programmers.

9http://supportforums.blackberry.com/t5/Java-Development/tkb-p/java_dev@tkb

6.8.1. BlackBerry App World

BlackBerry App World (figure 6.13) is an application distribution service and application by Research In Motion for certain BlackBerry devices. The service provides BlackBerry users with an environment to browse, download, and update third-party applications. The service went live on April 1, 2009. Please see table 6.3 and chapter 11 for more information on BlackBerry App World.

Figure 6.13. BlackBerry App World

 

Tip

On the BlackBerry, apps can’t be stored on a media card, causing a very limited number of applications to be loaded on a device for use at one time.

 

6.9. Windows Mobile

Windows Mobile is a compact operating system combined with a suite of basic applications for mobile devices based on the Microsoft Win32 API. Devices that run Windows Mobile include Pocket PCs, smartphones, Portable Media Centers, and onboard computers for certain automobiles.

Originally appearing as the Pocket PC 2000 operating system, Windows Mobile has been updated multiple times, the previous version being Windows Mobile 6.5 released in Fall 2009. Windows Phone 7 is the latest version of Windows Mobile and was announced on February 7, 2010, with the SDK release date of September 16, 2010.

Creating programs that run on Windows Mobile phones is very similar to writing apps for the Windows desktop. You use the same tools such as Visual Studio and publish apps to the Windows Marketplace for Mobile.

6.9.1. Windows Marketplace for Mobile

Windows Marketplace for Mobile (figure 6.14) is an application and service by Microsoft for their Windows Mobile platform that allows users to browse and download applications that have been developed by third parties. The application is now available for use directly on Windows Mobile 6.5 devices and on personal computers. It was announced at the 2009 Mobile World Congress and was released on October 6, 2009. Please see table 6.3 and chapter 11 for more information.

Figure 6.14. Windows Marketplace for Mobile

Windows Marketplace for Mobile, available through applications for Windows Mobile and personal computers, offers a 24-hour return policy for buyers, and 70% of each application sale is paid to developers. Microsoft charges a onetime US$99 fee for developers to list up to five applications yearly. After the five applications have been listed for the year, each additional application can only be listed with another US$99 fee. Please see table 6.3 for more information.

6.10. LiMo

The LiMo (Linux Mobile) Foundation was founded in January 2007 by Motorola, NEC, NTT DoCoMo, Panasonic Mobile Communications, Samsung Electronics, and Vodafone with the goal of establishing a globally competitive, Linux-based operating system for mobile devices. Since then, the foundation has expanded to more than 50 members who are working together within an open and transparent governance model—with shared leadership and shared decision making—to deliver an open and globally consistent handset software platform based on Linux for use by the whole mobile industry. See figure 6.15 for an overview of the LiMo architecture.

Figure 6.15. LiMo architecture (source: mng.bz/t946)

It has a modular plug-in architecture and supports DRM. LiMo application developers will be able to use SDKs to write managed code running in a Java virtual machine, browser apps for WebKit, and native code. As you can see in figure 6.15, the platform runs on top of the Linux kernel with middleware that provides the basic functionality.

Orange and Access have licensed LiMo to develop cellular telephone handsets, but at this point it’s not clear if LiMo will become a major platform that’s going to be worth development resources.

6.11. MeeGo

Moblin, developed by Intel, and Maemo, developed by Nokia, were merged into a single project named MeeGo in February 2010. MeeGo is slated to build on the Moblin core operating system, with Qt being the application development environment. It will be hosted in a completely open fashion by the Linux Foundation, so everybody can join in. It will run on pocketable mobile computers, netbooks, tablets, mediaphones, connected TVs, in-vehicle infotainment systems, and more.

Let’s take a quick look at Moblin and Maemo to understand the basics of MeeGo.

Moblin, short for Mobile Linux, is an open source operating system and application stack for mobile internet devices (MIDs), netbooks, and nettops. Built around the Intel Atom processor, current builds are designed to minimize boot times and power consumption to create a netbook and MID-centric operating system. See figure 6.16 for an overview of the Moblin architecture.

Figure 6.16. Moblin architecture (source: mng.bz/XRT6)

Moblin is built on top of the Linux kernel with App and UI services layers. It also has a very specific platform UI that’s intended for mobile devices such as smartphones and netbooks.

Intel launched the Moblin.org site in July 2007 and significantly updated the site in April 2008 with the launch of the Intel Atom processor family at the Intel Developer Forum in Shanghai. A custom SDK is also available on the site. The Moblin 2 OS was specifically designed to run on an Intel Atom processor in a netbook. In April 2009 Intel turned Moblin over to the Linux Foundation. Commercial products built around Moblin 2 include a Foxconn netbook and an InvenTech smartphone.

Maemo is a software platform developed by Nokia for smartphones and internet tablets. The first phone to run Maemo is the Nokia N900.

Maemo is a modified version of the Debian Linux distribution, slimmed down for mobile devices. It uses an X Window System–based graphical user interface using Xomap and the Matchbox window manager; the GUI uses the GTK+ toolkit and Hildon user interface widgets and API.

Although Maemo is based on Linux and open source software, some parts of Maemo remain closed source. Some user-space software, like certain status bar and taskbar applets (including the display brightness applet) and applications, and some system daemons related to connectivity and power management are not open source like the rest of the system.

Applications for Maemo can be developed in C using the Maemo SDK, in Java, which is supported by the Jalimo JVM, in Python, Ruby, and Mono.

Nokia dropped Symbian for its N-series high-end phones in favor of Maemo, so it’s expected that Maemo will become more and more important. Maemo applications will also be available in Nokia’s Ovi Store.

6.12. BREW

BREW (Binary Runtime Environment for Wireless), debuted in September 2001, is an application development platform created by Qualcomm for mobile phones. It was originally developed for CDMA handsets but has since been ported to other air interfaces including GSM/GPRS.

BREW is a software platform that can download and run small programs for playing games, sending messages, sharing photos, and the like. The main advantage of BREW platforms is that the application developers can easily port their applications between all Qualcomm devices. BREW acts between the application and the wireless device on-chip operating system in order to allow programmers to develop applications without needing to code for system interface or understand wireless applications. See figure 6.17 for an overview of the BREW architecture.

Figure 6.17. BREW architecture (source: mng.bz/S0aX)

BREW development usually takes too long and carriers have to certify apps (which may take up to two weeks of testing). Because of this, there’s a very high cost of entry to BREW development. After an application is written, it takes two weeks per iteration of True BREW testing (each time the application fails the test). Next, negotiations with carriers commence. Then (if successful) the carrier will spend time retesting the application with its own tests on its network. Finally, rolling out a new version means starting the process over again.

 

Tip: BREW and Java ME

Java ME is widely used in Europe, whereas BREW used to be primarily used in the United States and Japan. Even in the United States, Java ME phones used to have a larger market share than BREW-enabled phones.

There are now commercial technologies to fully automate porting from Java ME to BREW. This reduces the entry barrier to produce BREW applications by eliminating the need to develop two versions of the same application in both Java and C/C++.

 

Sometimes it may not be necessary to create applications from scratch. Some applications can be created using mobile development frameworks.

6.13. Mobile development frameworks

You can also create mobile applications without any coding at all by using a framework. Although these frameworks are definitely limited in functionality, knowing what they can and can’t do is recommended. Let’s look at some available mobile development frameworks.

6.13.1. PhoneGap

PhoneGap[10] is an open source development tool for building fast, easy mobile apps with JavaScript. For web developers who want to build mobile applications in HTML and JavaScript while still taking advantage of the core features in the iPhone, Android, and Blackberry SDKs, PhoneGap is a viable choice. Table 6.5 lists the capabilities of PhoneGap for various platforms.

10http://www.phonegap.com/

Table 6.5. PhoneGap platform capabilities
 

iPhone

Android

BlackBerry

Geolocation Yes Yes Yes
Vibration Yes Yes Yes
Accelerometer Yes Yes Pending
Sound Yes Yes Yes
Support Yes Pending Yes

6.13.2. Kyte Mobile App Frameworks

Kyte Mobile App Frameworks[11] is a turnkey solution that allows Kyte partners to create applications that can include video, live chat, and monetization options with a minimal amount of development costs.

11http://www.kyte.com/platform/pg/kyte_mobile_app_frameworks

6.13.3. Big5

Big5[12] enables your web apps to access the accelerometer data, get the current geo position, use the built-in camera, and more, similar to PhoneGap, but all applications run in a single Big5Apps container.

12http://www.big5apps.com/

6.13.4. Titanium Mobile

Titanium Mobile[13] is a toolkit that’s similar to PhoneGap. It allows web apps to access platform APIs.

13http://www.appcelerator.com/

6.13.5. QuickConnect

QuickConnect[14] is a powerful, modular, simple-to-use application development library available for many languages and platforms. QuickConnect is currently available for iPhone, Android, and Mac JavaScript apps, Erlang/Yaws, and PHP.

14http://sourceforge.net/projects/quickconnect/

6.13.6. Rhodes Framework

Rhodes[15] is an open source framework to rapidly build native apps for all major smart-phone operating systems (iPhone, Windows Mobile, RIM, Symbian, and Android). These are true native device applications (not mobile web apps), which work with synchronized local data and take advantage of device capabilities such as GPS, PIM contacts, and camera.

15http://rhomobile.com/

Every mobile application has to be tested extensively before being submitted to an app store, and there are ways of making this cost effective for the developers.

6.14. Testing

Testing your mobile application on every target device is an important part of the development process. Because each device may have different underlying implementations of the APIs you’re using, you have to test your app on each target device. When you have a Java ME application, you may easily end up having to test on tens or hundreds of different hardware platforms, which may become overwhelming and sometimes impractical if you don’t have the resources to purchase and maintain hundreds of phones.

Services like DeviceAnywhere[16] and Intertek[17] enable developers to remotely access multiple mobile phones and install and test their applications on them. For example, DeviceAnywhere maintains over 2,000 mobile devices that can be accessed over the internet for testing your applications.

16http://www.deviceanywhere.com/

17http://www.intertek.com/wireless-mobile/

And Mob4Hire[18] enables crowd testing of mobile applications. Mob4Hire’s website connects testers all over the world with developers who need their apps tested on multiple handsets and operating systems. Mob4Hire takes a 15% cut, and PayPal takes its customary 2.9% service fee plus 30 cents per transaction. The testers get paid to run the app on their phones and report what they find. With all the fees, testing this way still costs much less than deploying a company’s ranks to set up testing in other locales.

18http://www.mob4hire.com/

6.15. Summary

The mobile development landscape has completely changed with major disruptions, mostly from Apple and Google in the form of the iPhone and Android, respectively. Carriers have lost power, and this power has shifted to the phone manufacturers and developers.

Currently the best platforms for location-based services are the iPhone and the Android. These two platforms support easy retrieval of the device location, unlike other platforms that require you to maintain a cell tower database. RIM also announced some new platform APIs supporting GPS, but they aren’t widely deployed yet.

Android seems to be the most promising platform with a plethora of new devices coming out from almost every phone manufacturer, but iPhone is definitely the mobile device to beat at the moment.

Also, HTML5 is very promising for writing browser-based LBS apps that also run in mobile browsers.

Current app stores are still major pain points for developers. What used to be carriers’ verification programs are now approval processes with some app stores. When developing apps for these types of app stores, you have to plan accordingly. Your app can be rejected, or the approval process may take too long for you to make any reasonable bug fix releases.

The second major issue with app stores is visibility. For the moment, not all app stores have implemented smart filtering and recommendations. They display only the top 50 apps, so there’s a very long tail of apps that don’t sell well or get downloaded much.

As always, Java ME is supposed to run on every phone, but in reality it doesn’t. You need to test your application on all the target devices.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset