CH 1
CH 1
CH 1
Development
Moblie 1
Chapter One: Introduction
• What is Android?
A software stack for mobile devices that includes
– An operating system
– Middleware
– Key Applications
Uses Linux to provide core system services
– Security
– Memory management
– Process management
– Power management
– Hardware drivers
Moblie 2
General Features
• Messaging
SMS and MMS are available forms of messaging, including threaded text messaging
Android Google Cloud Messaging (GCM) is also a part of Android Push Messaging
service.
• Web browser
The web browser available in Android is based on the open-source Blink (previously
WebKit) layout engine.
Moblie 3
Connectivity Features
• Connectivity
Android supports connectivity technologies including GSM/EDGE, Wi-Fi,
Bluetooth, LTE, CDMA, EV-DO, UMTS, NFC, IDEN and WiMAX.
• Bluetooth
Supports voice dialing and sending contacts between phones, sending files
(OPP), accessing the phone book (PBAP), A2DP and AVRCP.
Keyboard, mouse and joystick (HID) support is available in Android 3.1+, and
in earlier versions through manufacturer customizations and third-party
applications.
Moblie 4
Media Features
Moblie 5
Media support
Moblie 6
Con’t
Moblie 7
External storage
• Most Android devices include microSD slot and can read microSD cards
formatted with FAT32, Ext3 or Ext4 file system.
Moblie 8
Advantage Android
Multitasking
Ease of Notification
Moblie 9
Disadvantage of Android
• Reading Assignment
Moblie 10
Android Architecture
Moblie 11
Environment
Android application development on either of the following operating
systems:
Moblie 12
Con’t
• Develop Android applications are freely available and can be downloaded
from the Web.
Following is the list of software's you will need before you start your Android
application programming.
• Java JDK5 or JDK6
• Android SDK
• Eclipse IDE for Java Developers (optional)
• Android Development Tools (ADT) Eclipse Plugin (optional)
Moblie 13
Setup Java Development Kit (JDK)
• You can download the latest version of Java JDK from Oracle's Java site:
Java SE Downloads. You will find instructions for installing JDK in
downloaded files, follow the given instructions to install and configure the
setup.
• Finally, set PATH and JAVA_HOME environment variables to refer to the
directory that contains java and javac, typically java_install_dir/bin and
java_install_dir respectively.
Moblie 14
Setup Android SDK
• You can download the latest version of Android SDK from Android’s official
website: http://developer.android.com/sdk/index.html.
• If you are installing SDK on Windows machine, then you will find
ainstaller_rXX-windows.exe, so just download and run this exe which will
launch Android SDK Tool Setup wizard to guide you throughout the
installation, so just follow the instructions carefully.
• Finally, you will have Android SDK Tools installed on your machine.
Moblie 15
Step 3 - Setup Eclipse IDE
• All the examples in this tutorial have been written using Eclipse IDE. So we
would suggest you should have latest version of Eclipse installed on your
machine.
• To install Eclipse IDE, download the latest Eclipse binaries from
http://www.eclipse.org/downloads/. Once you have downloaded the
installation, unpack the binary distribution into a convenient location. For
example in C:\eclipse on windows, or /usr/local/eclipse on Linux and
finally set PATH variable appropriately.
• Eclipse can be started by executing the following commands on windows
machine, or you can simply double click on eclipse.exe
Moblie 16
Step 4 - Setup Android Development Tools
(ADT) Plugin
• This step will help you in setting Android Development Tool plugin for
Eclipse.
• Let's start with launching Eclipse and then, choose Help > Software
Updates > Install New Software.
• This will display the following dialogue box
Moblie 17
Applications Component
• Application components are the essential building blocks of an Android
application.
• These components are loosely coupled by the application manifest file
AndroidManifest.xml that describes each component of the application
and how they interact.
Moblie 18
Con’t
• There are following four main components that can be used
within an Android application:
– Activities
– Services
– Broadcast Receivers
– Content Providers
Moblie 19
Activities
An activity represents a single screen with a user interface.
For example, an email application might have one activity that shows
a list of new emails, another activity to compose an email, and one
for reading emails.
If an application has more than one activity, then one of them should
be marked as the activity that is presented when the application is
launched.
An activity is implemented as a subclass of Activity class as follows:
public class MainActivity extends Activity
{
}
Moblie 20
Services
• A service is a component that runs in the background to perform long-
running operations.
• For example, a service might play music in the background while the user
is in a different application, or it might fetch data over the network
without blocking user interaction with an activity.
Moblie 21
Broadcast Receivers
• Broadcast Receivers simply respond to broadcast messages from other
applications or from the system.
• For example, applications can also initiate broadcasts to let other
applications know that some data has been downloaded to the device and
is available for them to use, so this is broadcast receiver who will intercept
this communication and will initiate appropriate action.
• A broadcast receiver is implemented as a subclass of BroadcastReceiver
class and each message is broadcasted as an Intent object.
public class MyReceiver extends BroadcastReceiver
{
Moblie 22
Content Providers
• A content provider component supplies data from one application to
others on request. Such requests are handled by the methods of the
ContentResolver class.
• The data may be stored in the file system, the database or somewhere
else entirely.
• A content provider is implemented as a subclass of ContentProvider class
and must implement a standard set of APIs that enable other applications
to perform transactions.
public class MyContentProvider extends ContentProvider
{
Moblie 23
Additional Components
• There are additional components which will be used in the construction of
above mentioned entities, their logic, and wiring between them. These
components are:
• Fragments
• Views
• Layouts
• Intents
• Resources
• Manifest
Moblie 24
Activity Class Inheritance Hierarchy
java.lang.Object
android.content.Context
android.content.ContextWrapper
android.view.ContextThemeWrapper
android.app.Activity
Moblie 25
Environment
• Android application development on either of the following operating
systems:
Moblie 26
Con’t
• All the required tools to develop Android applications are freely
available and can be downloaded from the Web.
• Following is the list of software's you will need before you start your
Android application programming.
• Android SDK
• If you are running Windows and have installed the JDK in C:\jdk1.6.0_15,
you would have to put the following line in your C:\autoexec.bat file.
Moblie 28
Step 2 - Setup Android SDK
• You can download the latest version of Android SDK from Android’s official
website: http://developer.android.com/sdk/index.html.
• If you are installing SDK on Windows machine, then you will find
ainstaller_rXX-windows.exe, so just download and run this exe which will
launch Android SDK Tool Setup wizard to guide you throughout the
installation, so just follow the instructions carefully.
• Finally, you will have Android SDK Tools installed on your machine.
Moblie 29
Step 3 - Setup Eclipse IDE
• All the examples in this tutorial have been written using Eclipse IDE. So we
would suggest you should have latest version of Eclipse installed on your
machine.
• To install Eclipse IDE, download the latest Eclipse binaries from
http://www.eclipse.org/downloads/. Once you have downloaded the
installation, unpack the binary distribution into a convenient location.
• For example in C:\eclipse on windows, or /usr/local/eclipse on Linux and
finally set PATH variable appropriately.
• Eclipse can be started by executing the following commands on windows
machine, or you can simply double click on eclipse.exe
Moblie 30
Step 4 - Setup Android Development Tools
(ADT) Plugin
• This step will help you in setting Android Development Tool plugin for
Eclipse.
• Let's start with launching Eclipse and then, choose Help > Software
Updates > Install New Software.
• This will display the following dialogue box
Moblie 31
Step 5 - Create Android Virtual Device
• To test your Android applications you will need a virtual Android device.
• So before we start writing our code, let us create an Android virtual
device.
• Launch Android AVD Manager using Eclipse menu options Window > AVD
Manager> which will launch Android AVD Manager.
• Use New button to create a new Android Virtual Device and enter the
following information, before clicking Create AVD button.
Moblie 32
Activity in Android
• Activity class is a pre-defined class in Android and every application which has
UI must inherit it to create window.
Moblie 34
The 7 lifecycle methods of android activity.
• onResume: called when activity will start interacting with the user.
Moblie 35
Additional Reading Assignment
• Software Architecture
• Android Brief History
• Android Versions
Moblie 36
Class Discussion
Moblie 37