ANDROID APPLICATION DEVELOPMENT

joyfulfightMobile - Wireless

Dec 10, 2013 (3 years and 7 months ago)

93 views

ANDROID APPLICATION
DEVELOPMENT
Android Overview
Android Architecture
¨
Run on top of Linux 2.6.
¨
Dalvik Virtual Machine optimized for mobile devices.
¨
Integrated browser based on the WebKit engine.
¨
Optimized graphics with OpenGL ES.
¨
SQLite database for structured data storage.
Recent Android Versions
Android Version
Name
API Level
1.5
Cupcake
3
1.6
Donut
4
2.0/2.1
Éclair
5-7
2.2.x
Froyo
8
2.3.x
Gingerbread
9-10
3.x.x
Honeycomb
11-13
4.X
Ice Cream Sandwich
Future combination of
Gingerbread and Honeycomb
Application Fundamentals
¨
Applications are written in the Java programming language.
¨
Compiled into an Android package file (.apk)
¨
Each application runs in its own sandbox and Linux process.
¨
Applications consist of components, a manifest file and
resources.
¨
Components:
¤
Activities
¤
Services
¤
Content Providers
¤
Broadcast receivers
Activities
¨
An activity represents a single screen with a user interface.
¨
Most applications contain multiple activities.
¨
When a new activity starts, it is pushed onto the back stack.
¨
User interface can be built with XML or in Java.
¨
Monitor lifespan through callback methods like onStart(),
onPause(), etc.
Services
¨
Services perform long-running operations in the background.
¨
Does not contain a user interface.
¨
Useful for things like network operations, playing music, etc.
¨
Runs independently of the component that created it.
¨
Can be bound to by other application components, if allowed.
Content Providers
¨
Used to store and retrieve data and make it accessible to all
applications.
¨
Are the only way to share data across applications.
¨
The way it works is to expose a public URI that uniquely
identifies its data set.
¨
Data is exposed as a simple table on a database model.
¨
Android itself contains many providers for things like contacts,
media, etc.
Broadcast Receivers
¨
A component that responds to system-wide broadcast
announcements.
¨
Examples include when the screen turn off, the battery is low,
etc.
¨
Your applications can also initiate their own broadcasts.
¨
Broadcast receivers contain no user interface.
¨
They can create status bar notifications to alert the user.
Android Manifest File
¨
Applications must have an AndroidManifest.xml file in its root
directory.
¨
Presents information about the application to the Android
system.
¨
Describes the components used in the application.
¨
Declares the permissions required to run the application.
¨
Declares the minimum Android API level that the application
requires.
Project Structure
¨
In Eclipse, click opens a wizard to help create a new android
project button.
Project Structure
¨
Create a new project
Project Structure
¨
Open Main.java which is located in src >
th.ac.netdesign.myfirstapp
¨
We will write the code in Main.java file.
Project Structure
¨
The setContentView() function will create a user interface for
our application.
¨
The user interface is located in res > layout > main.xml
Project Structure
¨
There are 2 tab for main.xml file which is Graphic Layout and
XML Layout.
Project Structure
¨
Let’s run the application by click run as.. > Android Application
Project Structure
¨
Open R.java file
Project Structure
¨
R.java file is an auto-generated code which refer to the
resources in the application.
Project Structure
¨
Open AndroidManifest.xml file
Project Structure
¨
The AndroidManifest.xml file is an ID card when we published
the application to the Android market.
¨
We can edit this file via a visual editor (4 tabs below) or
directly edit an xml file.