Introduction
Introduction
1. Introduction
What is Android?
Android is an open source and Linux-based Operating System for mobile
devices such as smart phones and tablet computers. Android was developed by
the Open Handset Alliance, led by Google, and other companies.
The Android SDK provides the tools and APIs necessary to begin applications
on the Android platform using the Java programming language.
The first beta version of the Android Software Development Kit (SDK) was
released by Google in 2007, whereas the first commercial version, Android 1.0,
was released in September 2008. On June 27, 2012, at the Google I/O
conference, Google announced the next Android version, 4.1 Jelly Bean.
The source code for Android is available under free and open source software
licenses. Google publishes most of the code under the Apache License version
2.0 and the rest, Linux kernel changes, under the GNU General Public License
version 2.
www.proworldtechnology.co.in 1 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
Features of Android
Android is a powerful operating system which supports great features. Few of
them are listed below:
Features Description
www.proworldtechnology.co.in 2 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
Android API
Name Version Number API Level
No name 1.0 1
Cupcake 1.5 3
Donut 1.6 3
O 8.0 26
www.proworldtechnology.co.in 3 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
2. Application Components
Key Terms
1. SDK (Software Development Kit): A set of tools and libraries that allow
the user to create an application based on a product.
2. IDE (Integrated Development Environment): A software application that
consists of a source code, editor, a compiler, build automation tools and a
debugger. It makes programming and running application easier.
3. ADT (Android Development Tools): A plugin for eclipse that extends the
Eclipse IDE by providing more tools to develop Android Applications.
4. AVD (Android Virtual Device): An android emulator that allows to
simulate how the application will run on an actual android device.
5. JDK (Java SE Development Kit): A popular Java SDK that is used to
program Android Application.
Components
There are following four main components that can be used within an Android
application:
Components Description
They dictate the UI and handle the user interaction to
Activities
the smart phone screen.
They handle background processing associated with
Services
an application.
They handle communication between Android OS
Broadcast Receivers
and applications
www.proworldtechnology.co.in 4 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
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:
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.
A service is implemented as a subclass of Service class as follows:
www.proworldtechnology.co.in 5 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
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
{
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.
www.proworldtechnology.co.in 6 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
Android Widgets
Android Button: This one of the most used components. It can be pressed
by a user and when pressed we can launch
Android Toast: Displays information for the short duration of time.
Custom Toast: Displays a customize the toast, such as we can display
image on the toast.
ToggleButton: It has two states ON/OFF.
CheckBox: It displays different checkboxes from which one can select
multiple options.
AlertDialog: AlertDialog displays a alert dialog containing the message
with OK and Cancel buttons.
Spinner: Spinner displays the multiple options, but only one can be
selected at a time.
RatingBar: RatingBar displays the rating bar.
DatePicker: Datepicker displays the datepicker dialog that can be used to
pick the date.
TimePicker: TimePicker displays the timepicker dialog that can be used
to pick the time.
ProgressBar: ProgressBar displays progress task.
ImageView: This component is used to show an image on the screen. The
image we want to show can be placed inside our apk or we can load it
remotely.
www.proworldtechnology.co.in 7 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
ArrayAdapter
Parameters
www.proworldtechnology.co.in 8 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
Layouts
When one create an app some special features are used which act as a container.
These special views control how other components are placed on the
smartphones screen. Android provides a collection of Layout Managers and
each of them implements a different strategy to hold, manage and place its
components. From the API point of view, all the Layout managers derive from
the ViewGroup class. There are some layouts that place the components
horizontally or vertically, and others that implement a different strategy.
Android provides several standard layout managers:
• Linear Layout: This is the simplest Layout manager. This layout disposes
its components vertically or horizontally depending on the orientation
parameter. The orientation attribute is the most important attribute
because it determines how views are placed. It can assume two values
that are horizontal or vertical.
• Table Layout: This is layout manager that disposes its components in a
table, grouping them in rows and columns.
• Relative Layout: This is the most flexible layout in Android. This layout
manager uses a policy where the container places its Views relative to
other Views. We can implement, using this layout manager, very
complex UI structures.
• Frame Layout: FrameLayout is a special layout that we will cover in
more detail later. We saw different layout manager that implements some
specific strategies to place views on the UI. FrameLayout is used when
we want to display dynamically a view. It is very useful when we use
Fragments.
www.proworldtechnology.co.in 9 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
www.proworldtechnology.co.in 10 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
www.proworldtechnology.co.in 11 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
www.proworldtechnology.co.in 12 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
Once the project is successfully created one will see the following window:
Android application contains different files such as java source code, string
resources, images, manifest file, apk file etc which are shown in following
figure:
www.proworldtechnology.co.in 13 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
Java Source: This contains the .java source files for project. By default,
it includes MainActivity.java source file having an activity class that runs
when the app is launched using the app icon.
Generated R.java: This contains the .R file, a compiler-generated file
that references all the resources found in the project. One should not
modify this file.
Bin: This folder contains the Android package files .apk built by the
ADT during the build process and everything else needed to run an
Android application.
www.proworldtechnology.co.in 14 [email protected]
9561702030
P r o W o r l d Technology Development of Android Apps
www.proworldtechnology.co.in 15 [email protected]
9561702030