1. Android Programming
• An Introduction ---
• Android is an
• Operating system
• Developed by Google
• For use in Notebooks
• & Mobile Phones.
2. Introduction
Android is a software bunch comprising not only
operating system but also middleware and key
applications. Android Inc was founded in Palo
Alto of California, U.S. by Andy Rubin, Rich
miner, Nick sears and Chris White in 2003. Later
Android Inc. was acquired by Google in 2005.
After original release there have been number of
updates in the original version of Android.
It is Java based and supports the
Google APIs
3. Main Features of
Android
Application framework enabling reuse and replacement of components.
Dalvik virtual machine optimized for mobile devices.
Integrated browser based on the open source WebKit engine .
Optimized graphics powered by a custom 2D graphics library; 3D
graphics based on the OpenGL ES 1.0 specification (hardware
acceleration optional).
SQLite for structured data storage.
Media support for common audio, video, and still image formats
(MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF).
GSM Telephony (hardware dependent).
Bluetooth, EDGE, 3G, and Wi-Fi (hardware dependent).
Camera, GPS, compass, and accelerometer (hardware dependent).
Rich development environment including a device emulator, tools for
debugging, memory and performance profiling, and a plug-in for the
Eclipse IDE.
5. Google APIs in Android
Google APIs Add-On is an extension to the Android SDK development environment that lets you
develop applications for devices that include Google's set of custom applications, libraries, and
services. A central feature of the add-on is the Maps external library, which lets you add powerful
mapping capabilities to your Android application.
The add-on also provides a compatible Android system image that runs in the Android Emulator,
which lets you debug, profile, and test your application before publishing it to users. The system
image includes the the Maps library and other custom system components that your applications
may need, to access Google services (such as Android C2DM). The add-on does not include any
custom Google applications. When you are ready to publish your application, you can deploy it to
any Android-powered device that runs a compatible version of the Android platform and that also
includes the custom Google components, libraries, and services.
The Google APIs add-on includes:
The Maps external library
The USB Open Accessory Library (only with API Levels 10 and 12+)
A fully-compliant Android system image (with the Maps library and other custom system
components built in)
A sample Android application called MapsDemo
Full Maps library documentation
6. Google Cloud API
Android Cloud to Device Messaging Framework
Android Cloud to Device Messaging (C2DM) is a
service that helps developers send data from
servers to their applications on Android devices.
The service provides a simple, lightweight
mechanism that servers can use to tell mobile
applications to contact the server directly, to
fetch updated application or user data. The
C2DM service handles all aspects of queueing of
messages and delivery to the target application
running on the target device.
7. Using Google Maps API
• Build location-based apps
• Build maps for mobile apps
• Visualize Geospatial Data Create 3D images
with the Earth API, heat maps in Fusion Tables
• Customize your maps Create customized maps
that highlight your data, imagery, and brand.
9. Google Earth API
Google Earth is available in Android Market
on most devices that have Android 2.1 or
later versions. So as devices such as Droid get
updated to Android 2.1, others will also be
able to fly to the far reaches of the globe with
a swipe of their finger.
Google Earth for Nexus One is used in the
Android Market.
10. Google Search API
• Google search and Google image search are
both available for Android.
• Free licensing is provided for
1000 searches per day.
11. Animations in Android
• Animations are supported in Android
both programmatically and directively.
12. Android Animation
Example (1)
HypatiaBasicAnimationActivity.java
package hypatia.animation.basic;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
public class HypatiaBasicAnimationActivity extends Activity {
/** Called when the activity is first created. */
static HypatiaAnimationView v;
static int[] colors={Color.WHITE,Color.YELLOW,Color.MAGENTA,Color.GREEN,Color.RED};
static int colorno=0;
@Override
public void onCreate(Bundle savedInstanceState) {
//This is the first method to be executed
super.onCreate(savedInstanceState);
v=new HypatiaAnimationView(this);//Create the view and store it in a static variable for further use
setContentView(v);//Make this view the current view. This means that whenever the view is invalidated it's onDraw method will be called
}
Android Animation
Example (1)
13. Android Animation
Example (2)
public class HypatiaAnimationView extends View implements AnimationListener {
String themessage="Reserve your right to think, for even to think wrongly is better than not to think at all.";
public HypatiaAnimationView(Context context) {
super(context);
paint = new Paint();
paint.setColor(HypatiaBasicAnimationActivity.colors[HypatiaBasicAnimationActivity.colorno]);
HypatiaBasicAnimationActivity.colorno=(HypatiaBasicAnimationActivity.colorno + 1) %
HypatiaBasicAnimationActivity.colors.length;
// TODO Auto-generated constructor stub
}
Paint paint;//The paint object for the drawing
@Override
public void onDraw(Canvas canvas)
{
super.onDraw(canvas);
if (hypatiaanimationset == null) {//If the animation set is null, create it
//***********************Create the Animation Set****************************
{
hypatiaanimationset=new AnimationSet(true);
animation = new AlphaAnimation(1F, 0F);
animation.setRepeatMode(Animation.REVERSE);
animation.setRepeatCount(Animation.INFINITE);
animation.setDuration(5000);
animation.setAnimationListener(this);
14. Data Access in
Android
• Android comes with a inbuilt SQLite
database.
• SQLite is a software library that implements a
self-contained, serverless, zero-configuration,
transactional SQL database engine. SQLite is
the most widely deployed SQL database
engine in the world. The source code for
SQLite is in the public domain.
15. Main Feature of SQLite
Main Feature of SQLite:-
Transactions are atomic, consistent, isolated, and durable (ACID) even after system crashes and power failures.
Zero-configuration - no setup or administration needed.
Implements most of SQL92. (Features not supported)
A complete database is stored in a single cross-platform disk file.
Supports terabyte-sized databases and gigabyte-sized strings and blobs. (See limits.html.)
Small code footprint: less than 350KiB fully configured or less than 200KiB with optional features omitted.
Faster than popular client/server database engines for most common operations.
Simple, easy to use API.
Written in ANSI-C. TCL bindings included. Bindings for dozens of other languages available separately.
Well-commented source code with 100% branch test coverage.
Available as a single ANSI-C source-code file that you can easily drop into another project.
Self-contained: no external dependencies.
Cross-platform: Unix (Linux, Mac OS-X, Android, iOS) and Windows (Win32, WinCE, WinRT) are supported out of
the box. Easy to port to other systems.
Sources are in the public domain. Use for any purpose.
Comes with a standalone command-line interface (CLI) client that can be used to administer SQLite databases.
16. A Simple Android SQL Lite
Program(1)
android.database.sqlite.SQLiteOpenHelper
This class needs to be subclassed to provide for creation of the database.
It has two methods
@Override
public void onCreate(SQLiteDatabase database) {
//Called when the database is created.
}
@Override
public void onUpgrade(SQLiteDatabase database, int oldversion, int newversion) {
//Called when the database is upgraded.
}
android.database.sqlite.SQLiteDatabase
Encapsulates a connection to a SQLite database and provides methods for sending queries to the
Database and recovering the result.
android.database.Cursor
This class provides methods for accessing the results of a select query.It can be compared to the
java.sql.ResultSet.
19. Web Services in
Android
• A Web Service is a XML based system for
implementing Remote Procedure Calls.
• It uses SOAP , the Simple Object Access
Protocol for accessing the Remote Object.
• The WSDL or Web Services description
Language is used to describe the methods in
the Web Service.
21. Conclusion
Android is a truly open, free developement platform based on linux
and open source. Handset makers can use and customize the
platform without paying a royalty.
A component-based architecture inspired by Internet mash-ups.
parts of one application can be used in another in ways not
originally envisioned by the developer. can use even replace built-
in components with own improved version.
This will unleash a new round of creativity in the mobile space.
Android is open to all : industry, developers and users.
Participating in many of the successful open source projects.
Aims to be as easy to build for as the web.
Google Android is stepping into the next level of mobile Internet.