Paper See how to create an example web service in Android. Page 174,  Chapter 6 Getting Started with Android – Alternative Formats See how to create an exa

Paper See how to create an example web service in Android. Page 174,  Chapter 6 Getting Started with Android – Alternative Formats
See how to create an example web service in iOS. Page 214,  Chapter 7 Getting Started with iOS – Alternative Formats

For submission : Read carefully about 2 different approaches for creating a web service from above. Then

Don't use plagiarized sources. Get Your Custom Essay on
Paper See how to create an example web service in Android. Page 174,  Chapter 6 Getting Started with Android – Alternative Formats See how to create an exa
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay

(a) compare the two approaches and

(b) explain 2 advantages of each approach relative to the other. Getting Started with Android
WHAT’S IN THIS CHAPTER?

! Deciding to target Android as your mobile platform

! Getting the tools you need to develop Android

! Creating a new project

! Creating the Derby project in Android

Android Inc. was initially started in 2003, out of a frustration with the smartphone market as
it existed at the time. It was acquired by Google in 2005.

The hardware side of Android is supported by the Open Handset Alliance (OHA), which
is a conglomeration of many handset manufacturers, and the software is maintained by the
Android Open Source Project, which is led by Google.

Android had its fi rst major release in late 2008; the fi rst major phone company to support it
was T-Mobile, and the original handset was the HTC Dream (G1).

The Android OS was built on a modifi ed Linux kernel and applications are written in Java. By
using Java as the development framework for the applications, Android enables you to develop
your application on all major platforms.

By leveraging the Eclipse IDE, Android affords the user almost the exact same user experience
for development on all major OS platforms.

Additionally, when researching Android you may come across the name Dalvik. It is the
virtual machine that runs on the Android device, and your applications run within it. What
does this mean to developers? Because your applications run inside this virtual space, it
provides a level of security to the base OS. Also, Dalvik has been designed with performance
in mind. As of Android 2.2 it also provides just-in-time compilation to your apps (because
Dalvik requires specially compiled .dex fi les and not just the standard .class fi les generated
in a normal Java compilation).

6

c06.indd 151c06.indd 151 28/07/12 6:01 PM28/07/12 6:01 PM

152 ” CHAPTER 6 GETTING STARTED WITH ANDROID

WHY TARGET ANDROID?
Among the many reasons to target the Android platform, fi rst and foremost is cost. On average
you can get an Android smartphone for a fraction of the cost of an iPhone. They may not have
commensurate features, but thrift is a major component for new smartphone buyers.

Next is fl exibility. More types of Android devices are available, so if your application fi ts a specifi c
niche market, there is probably a device that would support your needs already in production. At
the time of writing, there are effectively two iOS devices (iPhone/iPod touch and iPad); four if you
include the retina display versions, versus roughly 15 form factors to develop for.

If you are already a Java developer, adding Android to your repertoire is a snap. What Java is to
Android, Cocoa is to CocoaTouch and C# is to Silverlight. All of the frameworks that mobile
developers use are a combination of subsets and supersets of the functionality of a given technology.

Identifying an application that exists on another platform but does not yet exist on Android is
another perfectly good reason to target Android. That being said, you should do some research,
because if a developer has targeted iOS or BlackBerry as the primary platform, you have to assume
that Android is potentially on the horizon.

WHO SUPPORTS ANDROID?
HTC, LG, Motorola, and Samsung are the major players in the Android smartphone market.
Archos, Dell, Samsung, and Toshiba hold the largest pieces of the Android tablet market. You
should note that Amazon’s Kindle Fire and Nook Color are up-and-comers and use a customized
version of the Android tablet (Version 3) OS on their devices.

ANDROID AS COMPETITION TO ITSELF
Because Android was designed to be run on many different types of devices, created by many
different manufacturers (as opposed to the closed system that Apple has maintained), it has left
itself open to the will of said manufacturers. Because of the open nature of the Android OS, it is
commonplace for manufacturers to create vendor-specifi c builds of Android, and when this happens
you are beholden to them for OS updates. Additionally in these custom builds, vendor-specifi c
limitations have arisen such as the vendor-specifi c market. You then have another hurdle to cross
when releasing your application for sale to the public because some devices may not be able to
purchase it because of these limitations.

Another issue that has cropped up is the lack of over-the-air (OTA) distribution of OS updates by
cellular carriers. Often your device is perfectly capable of running a later version of the Android
software, but carriers are often slow to distribute that to their customers.

Multiple Markets and Market Locks
Depending on your version of Android, and depending on the manufacturer of a given device, you
may fi nd yourself locked into using a vendor-specifi c Android marketplace. Additionally, application

c06.indd 152c06.indd 152 28/07/12 6:01 PM28/07/12 6:01 PM

Getting the Tools You Need ” 153

vendors can list their application not only on Google Play or vendor-specifi c marketplaces, but
also on the Amazon App Store. You often fi nd on cheap and imported Android devices a version of
Google Play that is maintained by the manufacturer. They pick and choose what applications are
available from the whole set in the marketplace. You should develop as you expect to be available
to all Android devices; just note when purchasing large quantities for an enterprise deployment that
you will have to watch out for these inconsistencies.

The version of the Android SDK that you need to support depends on what devices you want to
support. If you want to target most phones available right now, you should support Android 2.2
or 2.3. “Gingerbread” (2.3) is the last widely available version for those devices. The Android 3.x
versions are for tablets, such as the Samsung Galaxy Tab. The Android 4.x versions are the newest,
and are a combination of the Android 2.x and Android 3.x functionality meant to pull back on the
version splintering seen in devices, but not many devices currently in release support it.

Once you have decided on a version to deploy your application against, you need to set up your
development environment. In the next section you will learn all about confi guring your IDE, Java
and Android SDKs, and building emulators.

GETTING THE TOOLS YOU NEED
This section paraphrases the installation instructions from the Android Developer section, and we
added some personal notes from our experiences.

Downloading and Installing JDK
The fi rst thing that you need to do to develop Android applications is to visit http://www.oracle
.com/technetwork/java/javase/downloads/index.html and ensure that you have the Java JDK
installed. Because so many different acronyms
and versions appear on the Java download
website, Figure 6-1 points you in the direction
you need to get past all of the potential
distractions on that site.

The JDK is the Java Development Kit. You
need this package to do any Java development
on your machine, Android or otherwise. Be
sure to look for the Java Platform, Standard
Edition JDK.

Downloading and
Installing Eclipse

After you have successfully installed the JDK,
you will need a development environment.
The open source IDE Eclipse is recommended by Android directly in its documentation. You are
not limited only to Eclipse, but the tooling has been honed over time to be the easiest solution to

FIGURE 6!1: JDK download page

c06.indd 153c06.indd 153 28/07/12 6:01 PM28/07/12 6:01 PM

154 ” CHAPTER 6 GETTING STARTED WITH ANDROID

get up and running. Figure 6-2 shows the Eclipse download page (www.eclipse.org/downloads).
Download the version of Eclipse Classic that is appropriate for your operating system.

FIGURE 6!2: Eclipse download site

Downloading and Installing the Android SDK
After you have installed the Eclipse IDE, you need to install the Android Software Developer Kit
(http://developer.android.com/sdk/index.html). This includes all the tools necessary to build
Android apps, because the SDK is not built directly into Eclipse. Figure 6-3 shows the Android SDK
download page; make sure to get the right version for your OS.

Don’t use the installer for 64-bit Windows. Just get the zip fi le and unzip it to
c:Android. At the time of writing the installer package has diffi culty fi nding
the Java SDK installed on the machine.

For Mac deploy it to /android in your root volume.

FIGURE 6!3: Android SDK download page

c06.indd 154c06.indd 154 28/07/12 6:01 PM28/07/12 6:01 PM

Getting the Tools You Need ” 155

Downloading and Confi guring the Eclipse ADT Plug-in
After you have installed the Android SDK you need the ADT plug-in. What this does is add the
features necessary to create Android Projects (and Android Test Projects), because they are not
bundled with the base Eclipse install. Additionally, the plug-in adds debugging tools to Eclipse to
help during the Android development process. Figure 6-4 shows the interface for installing the ADT
plug-in. You will also use this interface when upgrading ADT. The tooling generally gets a revision
when a new version of the Android OS is released.

FIGURE 6!4: Installing the ADT plug-in

Use the Update Manager feature of your Eclipse installation to install the latest revision of ADT on
your development computer. Follow these steps:

1. Start Eclipse and select Help # Install New Software.
2. Click Add in the top-right corner.
3. In the Add Repository dialog box that appears, enter ADT plug-in for the name and the

following URL for the location: https://dl-ssl.google.com/android/eclipse/.

4. Click OK. If you have trouble acquiring the plug-in, try using “http” in the Location URL
instead of “https” (“https” is preferred for security reasons).

5. In the Available Software dialog box, select the checkbox next to Developer Tools and
click Next.

c06.indd 155c06.indd 155 28/07/12 6:01 PM28/07/12 6:01 PM

156 ” CHAPTER 6 GETTING STARTED WITH ANDROID

6. The next window shows a list of the tools to be downloaded. Click Next.
7. Read and accept the license agreements and then click Finish. If you get a security warning

saying that the authenticity or validity of the software can’t be established, click OK.

8. When the installation completes, restart Eclipse.
Once you have downloaded the ADT plug-in you need to set it up to talk to the Android SDK that
you downloaded earlier. This allows Eclipse to build, run, and debug Android applications without
needing to open a terminal or command shell. Figure 6-5 shows where you need to add the link to
the Android SDK in the Eclipse preferences.

After you’ve successfully downloaded the ADT, the next step is to modify your ADT preferences in
Eclipse to point to the Android SDK directory (see Figure 6-5):

1. Select Window # Preferences to open the Preferences panel. In Mac OS X, click Eclipse #
Preferences.

2. Select Android from the left panel.
3. You may see a dialog box asking whether you want to send usage statistics to Google. If

so, make your choice and click Proceed. You cannot continue with this procedure until you
click Proceed.

4. For the SDK Location in the main panel, click Browse and locate your downloaded SDK
directory.

5. Click Apply and then click OK.

FIGURE 6!5: ADT confi guration screen

c06.indd 156c06.indd 156 28/07/12 6:01 PM28/07/12 6:01 PM

Getting the Tools You Need ” 157

Installing Additional SDK Components
The last step in preparing your development environment for Android is to download additional
Android OS packages. This enables you to build applications that target that OS, and also gives you
the tools you need to emulate a device running that OS on which to test all of your applications,
whether or not they have been targeted to that OS version. Figure 6-6 shows just how many options
you have when looking to target Android OS versions.

FIGURE 6!6: Working with the SDK Manager

Correctly confi guring and using this tool will ensure that you have all the latest SDKs and utilities
afforded to you. Note that you will not necessarily need all of the versions of the SDKs listed in
Figure 6-6; this was merely to illustrate the full breadth of your options.

Loading the Android SDK Manager in Eclipse takes only a few steps:

1. Open Eclipse.
2. Select Window # Android SDK and AVD Manager.

c06.indd 157c06.indd 157 28/07/12 6:01 PM28/07/12 6:01 PM

158 ” CHAPTER 6 GETTING STARTED WITH ANDROID

3. Select Available Packages in the left panel. This reveals all of the components that are cur-
rently available for download from the SDK repository.

4. Select the component(s) you’d like to install and click Install Selected.
5. Verify and accept the components you want (ensure each one is selected with a green check-

mark) and click Install. The components will now be installed into your existing Android
SDK directories.

I recommend that you download and install an Android 2.2.x, Android 2.3.x,
and Android 3.x version. This will give you the latest two handset-specifi c
versions of Android, and the current tablet version of Android. As Android
4.0 is so new, you may choose to get it, but understand that you may need to
purchase a newer device to test apps targeted to that version.

Development
The following sections discuss the application layout and Android app development.

Creating a New Project
First things fi rst — you need to create a new Android project. The line highlighted in Figure 6-7 is
the type of project you want.

FIGURE 6!7 Creating a new Android project

c06.indd 158c06.indd 158 28/07/12 6:01 PM28/07/12 6:01 PM

Getting the Tools You Need ” 159

First you need to name your application and
add it to a workspace. Think of a workspace
as the folder in which your application resides.
Figure 6-8 illustrates what the New Android
Project screen looks like.

After you have named your application
you will need to give it a package name,
set the minimum SDK required to run your
application, and name the initial Activity that
will run when your application runs. If you
want to add a test project to your workspace,
you can do so at this time. Figure 6-9 shows
a completed Application Info step in the new
project wizard.

An important note at this point: Make sure
that your package name is unique. The
standard format for package names is
com.companyName.applicationName. This
must be unique because that is how it is known
on the Android device and in the Android
Market. When you make updates you can make
them only within your package name. If you
change your package name there will be no
upgrade path between versions.

The minimum SDK required is generally set
when you are leveraging a permission or piece
of functionality that did not exist when the core
Android version was released, or if you want
to target a specifi c type of device (tablet versus
handset). The major jumps are between 1.6
and 2.1, 2.3 and 3.x, and 3.x and 4.x.
Figure 6-10 shows you all of the SDKs that you
have installed that you can target when creating
your application. Please note that the reason
this screen is full of SDKs is because I took the
time to download them all for demonstration
purposes.

FIGURE 6!8: Naming your project

FIGURE 6!9: Confi guring application information

c06.indd 159c06.indd 159 28/07/12 6:01 PM28/07/12 6:01 PM

160 ” CHAPTER 6 GETTING STARTED WITH ANDROID

This step is also very important when building your application. The minimum SDK version you
set specifi es the lowest possible version of the SDK in which your application will run, and it is the
primary version in which your application will run. Android 1.5 is the lowest version of the SDK
still supported, and Android 4.0.3 (at the time of this writing) is the highest.

FIGURE 6!10: Choosing the SDK version for your app

Figure 6-10 shows a Google version of the SDK alongside all of the versions I
have installed on my machine. The Google APIs add additional functionality to
each API Level. Please use your best judgment when deciding whether to use the
Google APIs, and research if you need the functionality they provide.

Project Structure
The major sections to note in Figure 6-11 are the src and res folders and the AndroidManifest
.xml fi le. It shows the project layout for the application that I have been building in the
previous steps.

c06.indd 160c06.indd 160 28/07/12 6:01 PM28/07/12 6:01 PM

Getting the Tools You Need ” 161

All of your code lives within your src folder, under your Package
Namespace. The res folder holds layouts and resources for different
hardware specs. HDPI, LDPI, and MDPI are the resolutions for which
you can create images. The layout subfolder holds all of your XML
layouts. These are how your application gets rendered. The code will
be how to populate these layouts. All of your XML layouts are stored
in the layout subfolder of res, and your code will be linked under the
namespace in your src folder of the project view.

The Android Manifest is the heart of your application. It holds the entire
confi guration of your app (Figure 6-12) — the permissions you request
(Figure 6-14), the application attributes (Figure 6-13), and links to
instrumentation to be attached to your app. You can edit this in Eclipse’s
Manifest Editor or in XML (Figure 6-15) because that is how it is saved.

FIGURE 6!11: Basic project
structure

FIGURE 6!12: Main Manifest Editor

c06.indd 161c06.indd 161 28/07/12 6:01 PM28/07/12 6:01 PM

162 ” CHAPTER 6 GETTING STARTED WITH ANDROID

The Manifest Editor is where the initial information of your application is stored when you create
it. This interface also has links to export your application. Exporting is necessary when submitting
your app to Google Play. In Eclipse there is a specifi c menu option and wizard that expedites the
submission process.

Figure 6-13 shows all of the base properties that can be set for a given application in the app’s
AndroidManifest.xml fi le. The most common properties to edit are the Label (the text shown
under the icon, often referenced in a resource fi le) and Icon (the icon shown in the launcher UI of
your device, the icon your users will click on to launch the app).

FIGURE 6!13: Manifest Application Info Editor

The spartan view shown in Figure 6-14 is the Permissions Editor. Here you can add permission
requests to your application. The most common one is android.permission.INTERNET,
which allows the application to use the device Internet connectivity. This, along with GPS and
accelerometer, are the permissions you will add to the Derby Names application.

c06.indd 162c06.indd 162 28/07/12 6:01 PM28/07/12 6:01 PM

Getting the Tools You Need ” 163

Last is the XML Editor shown in Figure 6-15. As you make changes in the other tabs they are
refl ected here. If you feel more comfortable editing the XML by hand you can use this interface to
add, update, and remove properties as you see fi t.

FIGURE 6!14: Android Manifest Permissions Editor

FIGURE 6!15: Android Manifest XML Editor

c06.indd 163c06.indd 163 28/07/12 6:01 PM28/07/12 6:01 PM

164 ” CHAPTER 6 GETTING STARTED WITH ANDROID

Android Basics
You have two options for starting your application. You can build the layout you would like
to populate, or you can build the code that will populate the layout. Either is acceptable; it just
depends on what you feel most comfortable with.

Creating User Interfaces
This section describes the common widgets that come with Android, and shows examples of the
different layout elements you can use to coordinate the fl ow of your application’s activities.

Basic Android UI Elements
All of the basic elements in Android are stored in the android.widgets namespace in the SDK.

The most commonly used elements include:

! Button: This is a standard button element.

The following XML specifi es the layout of the Button widget:

Quick Homework Essays
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.