Chapter 2 Basics in Android Programming By Dr. Ramkumar Lakshminarayanan Objectives 2.1 Preparing the Environment for the Android Programming 2.2 Construction of Android Sample Application Introduction The Android operating system software stack consists of Java applications running on a Java based object oriented application framework on top of Java core libraries running on a Dalvik virtual machine featuring JIT compilation. Libraries written in C include the surface manager, OpenCore media framework, SQLite relational database management system, OpenGL ES 2.0 3D graphics API, WebKit layout engine, SGL graphics engine, SSL, and Bionic libc. To develop an Application Google provides Android SDK and Android NDK. The Android SDK provides the API libraries and developer tools necessary to build, test, and debug apps for Android. In this chapter we will discuss about setting up an environment for creating Android Application and creating an sample application. Android Developer Tools Google Provides free tools for developing Android Applications. Android Developer Tools (ADT) can be downloaded from http://developer.android.com. ADT Bundles includes the following:
The Android operating system software stack consists of Java applications running on a Java based object oriented application framework on top of Java core libraries running on a Dalvik virtual machine featuring JIT compilation. Libraries written in C include the surface manager, OpenCore media framework, SQLite relational database management system, OpenGL ES 2.0 3D graphics API, WebKit layout engine, SGL graphics engine, SSL, and Bionic libc. To develop an Application Google provides Android SDK and Android NDK. The Android SDK provides the API libraries and developer tools necessary to build, test, and debug apps for Android. In this chapter we will discuss about setting up an environment for creating Android Application and creating an sample application.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Chapter 2
Basics in Android Programming
By
Dr. Ramkumar Lakshminarayanan
Objectives
2.1 Preparing the Environment for the Android Programming
2.2 Construction of Android Sample Application
Introduction
The Android operating system software stack consists of Java applications running on a Java based object oriented application framework on top of Java core libraries running on a Dalvik virtual machine featuring JIT compilation. Libraries written in C include the surface manager, OpenCore media framework, SQLite relational database management system, OpenGL ES 2.0 3D graphics API, WebKit layout engine, SGL graphics engine, SSL, and Bionic libc. To develop an Application Google provides Android SDK and Android NDK. The Android SDK provides the API libraries and developer tools necessary to build, test, and debug apps for Android. In this chapter we will discuss about setting up an environment for creating Android Application and creating an sample application.
Android Developer Tools
Google Provides free tools for developing Android Applications. Android Developer Tools (ADT) can be downloaded from http://developer.android.com.
ADT Bundles includes the following:
Eclipse + ADT plugin
Android SDK Tools
Android Platform-tools
The latest Android platform
The latest Android system image for the emulator
Operating System that can be used for the development is:
Windows XP (32-bit), Vista (32- or 64-bit), or Windows 7 (32- or 64-bit)
Mac OS X 10.5.8 or later (x86 only)
Linux (tested on Ubuntu Linux, Lucid Lynx)
o GNU C Library (glibc) 2.7 or later is required.
o On Ubuntu Linux, version 8.04 or later is required.
o 64-bit distributions must be capable of running 32-bit applications.
IDE support for Android Development is as follows:
Eclipse 3.6.2 (Helios) or greater.
Eclipse 3.5 (Galileo) is no longer supported with the latest version of ADT.
Eclipse JDT plug in (included in most Eclipse IDE packages)
JDK 6. JRE alone is not sufficient
Android Development Tools plugin
Setting the Environment using ADT Bundle
The ADT Bundle includes everything for developing an Android Application. Once it is downloaded from the developer.android.com unzip the pack to a folder, for example D:\Android\
Install JDK6 which is the pre-requisite for Android tools. After Extraction and installation open the folder D:\Android\Eclipse and launch eclipse. Now the IDE is ready for developing the Android Application.
Getting Started with the first Project
1. Click New in the toolbar.
2. In the window that appears, open the Android folder, select Android Application Project, and click Next
3. Fill in the form that appears:
Application Name is the app name that appears to users. For this project, use "LearnApp"
Project Name is the name of your project directory and the name visible in Eclipse.
Package Name is the package namespace for your app (following the same rules as packages in the Java programming language). Your package name must be unique across all packages installed on the Android system. For this reason, it's generally best if you use a name that begins with the reverse domain name of your organization or publisher entity. For this project, you can use something like "com.mjs.learnapp." However, you cannot publish your app on Google Play using the "com.mjs" namespace
Figure 2.1 New Android App Wizard Project
Minimum Required SDK is the lowest version of Android that the app supports. While the latest versions of Android often provide great APIs for your app, you should continue to support older versions of Android until more devices get updated. API Level is an integer value that uniquely identifies the framework API revision offered by a version of the Android platform.
Target SDK indicates the highest version of Android with which you have tested with your application.
Compile With is the platform version against which you will compile your app. By default, this is set to the latest version of Android available in your SDK.
Theme specifies the Android UI style to apply for your app. You can leave this alone.Click Next
4. On the next screen to configure the project, leave the default selections and Click Next
Figure 2.2 Configure Project
5. The next screen can help you create a launcher icon for your app. You can customize an icon in several ways and the tool generates an icon for all screen densities. Before you publish your app, you should be sure your icon meets the specifications.
Figure 2.4 Launcher Icon
6. Now you can select an activity template from which to begin building your app.
For this project, select BlankActivity and click Next.
Figure 2.5 Activity Template
7. Leave all the details for the activity in their default state and click Finish. Your Android project is now set up with some default files and you’re ready to begin building the app.
Figure 2.6 Project Setup
Exploring the Android Project Files
You will now see a new Android project called Droid1 in the Eclipse File
Explorer. In addition to linking the appropriate Android SDK jar file, the following core
files and directories are created:
• AndroidManifest.xml—The central configuration file for the application.
• project.properties—A generated build file used by Eclipse and the Android
ADT plug- in. Do not edit this file.
• /src folder—Required folder for all source code.
• /src/com.mjs.learnapp/MainActivity.java—Main entry point to this
application, named MainActivity. This activity has been defined as the default