Académique Documents
Professionnel Documents
Culture Documents
Android helps you take advantage of the hardware capabilities available on each device. It
automatically adapts your UI for each device while still giving you control over the UI.
With Android, you can create a single app that looks and works great on both phone and
tablet. You declare your UI in XML resources, one set for parts of the UI that are common
and another set for device specific optimization. At runtime, Android applies the correct
resource sets based on device parameters and specifications.
To help you develop efficiently, the Android Developer Tools offer a full Java IDE (Integrated
Development Environment) with advanced features for developing, debugging, and
packaging Android apps. You can use the IDE to develop your app for any available Android
device. You can also emulate any hardware device to test and optimize your app.
2.2.1: IDE:
Google Play is the most important marketplace for selling and distributing Android apps.
Google Play is owned and managed by Google. All Android devices can connect to Google
Play and download apps from it.
Google Play provides lot of flexibility in publishing, pricing and distributing your app. You can
decide which devices you want to make your app available on, Which countries you want to
sell in and how much to charge for it. You can sell your app for a fixed price or offer it as a
subscription service. You can also include in-app purchase and advertising to monetize your
app.
Windows XP (32 bit), Vista (32 or 64 bit), Windows 7 (32 or 64 bit) or Windows 8
Linux (i386)
The Java Development Kit (JDK) is an implementation of either one of the Java SE, Java EE
or Java ME platforms released by Oracle Corporation in the form of a binary product aimed
at Java developers on Solaris, Linux, Mac OS X or Windows.
1. Go to http://www.oracle.com/technetwork/java/javase/downloads/index.html in
your browser.
2. Click the JDK link under the Java Platform (JDK) heading
If you’re on a Mac, install the JDK through Software Update panel. A new Java SE
downloads page appears, asking you to specify which platform (Windows, Linux, or Mac)
you’ll be using for your development work.
5. In the Save As dialog box, select the location where you want to save the file
and click Save.
You should install the correct Java SDK version. Android 4.2.2 supports Java SDK versions
6 and 7.
When the download is complete, double-click the file to install the JDK. A dialog box appears
that asks whether you want to allow the program to make changes to your computer. Click
the Yes button.
1. If you don’t already have Eclipse, you can download it from the Eclipse website -
http://www.eclipse.org/downloads/index.php
1. Open Eclipse by double clicking it and a Workspace Launcher window will appear.
The window will display the default path for the workspace as C:\Documents and
Settings\username\workspace (where username is your login on the machine).
Change the location for the workspace if you want.
2. Check the box labelled Use this as the default and do not ask again. If you ever
want to re-enable the display of this window, once Eclipse starts, you can
3. Click OK
4. Download Course Library Jar into the same folder that you are using as your
workspace or move this file in the workspace folder after downloading it elsewhere.
10. In the Jar Selection window, navigate to your workspace folder, and double-click the
file cs15-1xx.library.
12. Close the Welcome window. You can always get it back by selecting Help |
Welcome
The Android SDK (Software Development Kit) includes a debugger, Android libraries, a
device emulator, documentation, sample code, and tutorials. The SDK ensures that your
code will have all the libraries needed to run your app on an Android device. This course
uses the official Android SDK. It is strongly recommended that you use the latest SDK for
developing your app.
5. If you’re prompted to accept the authenticity of the file, click Yes. The Android SDK
and AVD Manager dialog box opens.
6. Select any SDK Platform from Android 2.2 to Android 4.3 check box.
2.2 is the basic version of Android and 4.3 is the latest and greatest version of Android. You
should also check the boxes for the documentation and samples that correspond with
Android version.
While the Android SDK is attempting to connect to the servers to obtain the files, you may
occasionally receive a Failure to fetch URL error. If this happens, navigate to Settings, select
Force https:// Sources to be Fetched Using http://, and then attempt to download the
available packages again.
Android offers a custom plugin for the Eclipse IDE, called Android Development Tools
(ADT). This plugin provides a powerful, integrated environment in which you develop
Android apps. It extends the capabilities of Eclipse to let you quickly set up new Android
projects, build an app UI, debug your app, and export signed (or unsigned) app packages
(APKs) for distribution.
If you prefer to work in a different IDE, you do not need to install Eclipse or ADT. Instead,
you can directly use the SDK tools to build and debug your application.
3. In the Add Repository dialog that appears, enter "ADT Plugin" 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 plugin, try using "http" in the Location URL, instead
of "https".
6. In the next window, you'll see a list of the tools to be downloaded. Click Next.
If you get a security warning saying that the authenticity or validity of the software
can't be established, click OK.
Once Eclipse restarts, you must specify the location of your Android SDK directory:
1. In the "Welcome to Android Development" window that appears, select Use existing
SDKs.
2. Browse and select the location of the Android SDK directory you recently
downloaded and unpacked.
3. Click Next.
Your Eclipse IDE is now set up to develop Android apps, but you need to add the latest SDK
platform tools and an Android platform to your environment. To get these packages for your
SDK, continue to Adding Platforms and Packages.
If you are having trouble downloading the ADT plugin after following the steps above, here
are some suggestions:
If Eclipse cannot find the remote update site containing the ADT plugin, try changing
the remote site URL to use http, rather than https. That is, set the Location for the
remote site to:
http://dl-ssl.google.com/android/eclipse/
If you are behind a firewall, make sure that you have properly configured your proxy
settings in Eclipse. In Eclipse, you can configure proxy information from the main
Eclipse menu in Window > Preferences > General > Network Connections.
If you are still unable to use Eclipse to download the ADT plugin as a remote update site,
you can download the ADT zip file to your local machine and manually install it:
7. In the Available Software dialog, select the checkbox next to Developer Tools and
click Next.
8. In the next window, you'll see a list of the tools to be downloaded. Click Next.
If you get a security warning saying that the authenticity or validity of the software
can't be established, click OK.
To update your plugin once you've installed using the zip file, you will have to follow
these steps again instead of the default update instructions.
You will now create a new project using Eclipse with the ADT plugin. The Android SDK is
installed with your Eclipse.
2. In the New window, under Android folder, select Android Application Project, and
click Next.
o Application Name is the app name users see in the app store or on the
phone. Enter "News Reader".
o Project Name is the name of your project directory on your computer and in
Eclipse. Enter News Reader App.
o Package Name is the package namespace for your app. You must give a
unique package name for each app. Enter "com.yourname.newsreader."
Replace “yourname” with your name in this.
o Minimum Required SDK is the oldest version of Android that you want to
support for your app. You use API level to tell Android the oldest supported
version for your app. If you want to support more devices, keep this as low as
you can without impacting the app’s performance. Set it to 2.3.
o Target SDK is the Highest Android version you wish to support. You use
the API level for this also. You should try to use the latest version in order to
support new features of Android. Set it to 4.3.
o Compile With is the Android version against which you will compile your app.
By default, this is same as the SDK version installed on your computer. You
can compile your app to support older versions, but compiling for the latest
version will enable your app to use the new features and support new
devices. You do not need to set it as you will compile the news Reader app
for Android 4.3.
o Theme specifies the Android UI style to that your app will use.
Click Next.
5. You can create a custom launcher icon for your app. For now, you will accept the
default icon so unselect the check box Create custom launcher icon. You will
create a custom launcher icon in chapter 4. Click Next.
6. On the Create Activity dialog box, you can select an activity template to start
building your app. Select BlankActivity and click Next.
You are now ready to start building the News Reader app with default files and settings.
1. To open the AVD Manager, click the icon on the Eclipse toolbar.
2. Click the New button. The Create New Android Virtual Device (AVD) dialog box opens
5. In the SD Card section, leave the fields blank. You have no use for an SD Card in your
application.
The Hardware section outlines the hardware features your AVD should emulate. You don’t
need any extra hardware configuration for this application.
7. Click OK. The Android AVD Manager dialog box should now look like this
Once emulator has loaded, the locked home screen appears. To unlock the home screen,
click and drag the Lock icon to the right side of the screen. When the icon reaches the far
side of the screen, release the icon.
The ADT now starts the News Reader application for you.
Every Android project includes a special file called the Android manifest file. The Android
system uses this file to determine application configuration settings, including the
application’s identity as well as what permissions the application requires to run. We will
The manifest is made up of a root manifest tag with a package attribute set to the project’s
package. It usually includes an xmlns: android attribute that supplies several system
attributes used within the file. A typical manifest node is shown in the XML snippet below:
<manifest xmlns:android=http://schemas.android.com/apk/res/android
package=”com.yourname.newsreader”>
</manifest>
<manifest>
<uses-permission />
<permission />
<permission-tree />
<permission-group />
<instrumentation />
<uses-sdk />
<uses-configuration />
<uses-feature />
<supports-screens />
<compatible-screens />
<supports-gl-texture />
<application>
<activity>
<intent-filter>
<action />
<category />
<data />
</intent-filter>
<meta-data />
</activity>
<activity-alias>
<intent-filter> . . . </intent-filter>
<meta-data />
</activity-alias>
<receiver>
<intent-filter> . . . </intent-filter>
<meta-data />
</receiver>
<provider>
<grant-uri-permission />
<meta-data />
<path-permission />
</provider>
<uses-library />
</application>
</manifest>
Application: A manifest can contain only one application node. It uses attributes to specify
the metadata for your application including its title, icon, and theme. It also acts as a
container for other components.
</application>
Activity: An activity tag is needed for every Activity displayed by your application. The class
name can be specified using the android: name attribute. Trying to start an Activity that’s not
defined in the manifest will throw a runtime exception.
<intent-filter>
</intent-filter>
</activity>
Provider: Content Providers are used to manage database access and sharing within and
between applications.
android: name=”.NewsProvider”
android: enabled=”true”
android: authorities=”com.yourname.newsreader.NewsProvider”>
</provider>
Receiver: By adding a receiver tag, you can register a Broadcast Receiver without having to
launch your application first. By registering a Broadcast Receiver in the manifest, you can
make this process entirely autonomous. If a matching Intent is broadcast, your application
will be started automatically and the registered Broadcast Receiver will be run.
android: name=”.ContentReceiver”>
</receiver>
</uses-permission>
Permission: Permission tags are used to restrict the access to an application component.
Application components can then add them by using the android: permission attribute.
Within the permission tag, you can specify the level of access the permission will permit, a
label, and an external resource containing the description that explain the risks of granting
this permission.
<permission android:name=”com.yourname.DETONATE_DEVICE”
android: protectionLevel=”dangerous”
android: description=”@string/detonate_description”>
</permission>
android: name=”.TestClass”
android: targetPackage=”com.yourname.newsreader”>
</instrumentation>
To use the Manifest Editor in Eclipse, right-click the AndroidManifest.xml file in your project,
and select Open With ➪ Android Manifest Editor. This presents the Android Manifest
Overview screen, as shown below:
This gives you a high-level view of your application structure and provides shortcut links to
the Application, Permissions, Instrumentation, and raw XML screens.