Android Application Development Tutorial: by Chau Ngo EEL 6788-Advanced Topics in Wireless Networks
Android Application Development Tutorial: by Chau Ngo EEL 6788-Advanced Topics in Wireless Networks
Development Tutorial
By Chau Ngo
Android Market is an online software store developed by Google for Android devices
An application program ("app") called "Market" is preinstalled on most Android devices
and allows users to browse and download apps published by third-party developers,
hosted on Android Market
http://en.wikipedia.org/wiki/Android_(operating_system)
Current API Distribution
Version 1.0 was released on 23rd September 2008
Newest version, 3.0, was release on 26th January
2011.
Distribution as of 01/04/11
Android Architecture
5 major components: Applications, Application Frameworks, Libraries,
Android Runtime, and Linux Kernel
Platform Architecture Videos
Presenter: Mike Cleron, Android development team
member.
Video 1 of 3 (13 minute): architecture overview +
replacing and reusing components example
Application Components
An activity presents a visual user interface
Present a list of menu items users can choose
Display photographs along with their captions
Activities work together to form a cohesive user
interface, however each activity is independent of the
others.
Service doesn't have a visual user interface, runs in the
background for an indefinite period of time
Media player’s music playback service
Application Components
(Cont.)
Broadcast receiver: is a component that receives and reacts to
broadcast announcements
let other applications know that some data has been downloaded
to the device and is available for use.
Content provider :
Makes a specific set of the application's data available to other
applications
Enables other applications to retrieve and store data of the type it
controls
http://developer.android.com/guide/topics/fundamentals.html
Activity Life Cycle
http://developer.android.com/guide/topics/fundamentals.html
Android Features
Part 1
Application framework enabling reuse and replacement of components
http://developer.android.com/guide/basics/what-is-android.html
Android Features
Part 2
Media support for common audio, video, and still image formats (MPEG4,
H.264, MP3, AAC, AMR, JPG, PNG, GIF)
http://developer.android.com/guide/basics/what-is-android.html
Application Fundamentals
Written in the Java programming language.
Code along with any required data and resource files are
compiled into an Android package, .apk file.
Installed on mobile devices
Runs in its own Linux process
Has its own virtual machine (VM),
Is assigned a unique Linux user ID
Permissions are set so that the application's files are visible
only to that user and only to the application itself
http://developer.android.com/guide/topics/fundamentals.
html
Android Central Feature
Replace and Reuse
One application can make use of elements of other applications provided
those applications permit it.
One application doesn't incorporate the code of the other application or
link to it. Rather, it simply starts up that piece of the other application
when the need arises.
For this to work, the system must be able to start an application process
when any part of it is needed, and instantiate the Java objects for that part.
Unlike applications on most other systems, Android applications don't have
a single entry point for everything in the application (no main() function, for
example).
Rather, they have essential components that the system can instantiate and
run as needed.
http://developer.android.com/guide/topics/fundamentals.html
Intents
Is the 5th key class
Objects that hold the content of the message
Activities, services, and broadcast receivers — are activated by
intents
For activities and services, it names the action being requested
and specifies the URI of the data to act on, among other things
Request for an activity to present an image to the user or let the user
edit some text
For broadcast receivers, it names the action being announced
Announce to interested parties that the camera button has been pressed
http://developer.android.com/guide/topics/fundamentals.html
Manifest file
Before Android can start an application component, it must
learn that the component exists.
Applications must declare their components in a manifest file
Is a structured XML file, named AndroidManifest.xml for all
applications.
Declares the application's components
Names any libraries the application needs to be linked against
(besides the default Android library)
Identifies any permissions the application expects to be granted
http://developer.android.com/guide/topics/fundamentals.html
Manifest File Example
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloandroidtoo"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
<activity android:name=".HelloAndroid"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
android:debuggable="true"
</application>
<uses-sdk android:minSdkVersion="8" />
</manifest>
http://developer.android.com/guide/topics/fundamentals.html
Supported Operating Systems
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)
GNU C Library (glibc) 2.7 or later is required.
On Ubuntu Linux, version 8.04 or later is required.
64-bit distributions must be capable of running 32-bit
applications
Supported Development
Environments
Recommended: Eclipse
Eclipse IDE 3.4 (Ganymede) or greater
Eclipse IDE for Java Developers
Eclipse Classic (versions 3.5.1 and higher)
Eclipse IDE for Java EE Developers
Eclipse JDT plug-in (included in most Eclipse IDE packages)
JDK 5 or JDK 6 (JRE alone is not sufficient)
Android Development Tools plug-in (recommended)
http://developer.android.com/sdk/installing.html
Installing Java SDK
Website:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Takes about 5 minutes
Latest version: 1.6.23
Select the standard edition
Select platform
Check license agreement
Select file in the “Available Files”
Select “Run” to start installing
Accept all default settings unless you want to customize.
Don’t need immediate registration
Java SDK will be installed on C drive by default
For example: C:\Program Files\Java\jdk1.6.0_23
Java SDK Directory
Download Eclipse
http://www.eclipse.org/downloads/
Takes about 3 Minutes
Select package
Select zip file for your OS
Click on “Download”
On “File Download” dialog, select “Save” to save the .zip file
After zip file is completely downloaded, unzip it.
Eclipse application is located under “eclipse” folder
For example: C:\Users\chau\Desktop\eclipse-SDK-3.6.1-
win32\eclipse\
Eclipse Directory
Notes on Eclipse Tutorial
Instructions written based on older version
Missing steps
HelloWorld tutorial: check on “Create public static
main ….”
First time “Run as Java application” is not available
http://developer.android.com/guide/tutorials/hello-w
orld.html
Create Project
Select Android Project
Hello Android Tutorial
Step 2
Specify project properties
Project name: HelloAndroid
Build target: 2.2
Might need to create the target first (See Create AVD)
Application name: Hello, Android
Package name: com.example.HelloAndroid
Select “Create Activity” with “HelloAndroid” as name
Min SDK Version: 8
Click on “Finish” button.
http://developer.android.com/guide/tutorials/hello-world.html
Hello Android Tutorial
Step 3
Edit/Add code in the “onCreate” method
Comment out the following line
//setContentView(R.layout.main);
Add the following lines
TextView tv = new TextView(this);
tv.setText("Hello, Android!!!\nWhat's up urban?");
setContentView(tv);
Save the file , then Build the project if needed
SensorManager.SENSOR_ACCELEROMETER |
SensorManager.SENSOR_MAGNETIC_FIELD |
SensorManager.SENSOR_ORIENTATION,
SensorManager.SENSOR_DELAY_FASTEST);