a lap around android part 1
DESCRIPTION
A Lap Around Android I Presentation from SoCal Code Camp June 26 2010TRANSCRIPT
A Lap Around Android IBen Monro
June 26, 2010SoCalCodeCamp
2
Overview
Platform Overview The Emulator & DDMS Hands on walk through
Activities UI Components Intents Resources Dialogs
Questions & Answers
3
Android: The platform
4
Applications in Android
Written in Java Bundled into APK packages that include:
Compiled Java code Data, files & other resources required for the application to
install & run Runs in its own isolated process & java VM. Have a manifest file that defines the way the OS Launches
& interacts with the Application. Components of an Android App:
Activities Services Broadcast Receivers Content Providers – Activated by Content Resolver Intents are Asynchronous system messages that tell the OS
when/how to do something.
Activated by “Intents”
5
Activities
Activities are the core of Android App UIs. Made up of Views & View Groups (aka Layouts)
Examples of Views:▪ TextView / EditText▪ ListView / GridView▪ Gallery▪ Spinner▪ Button▪ ImageView▪ DatePicker
Layouts:▪ LinearLayout▪ RelativeLayout▪ TableLayout▪ AbsoluteLayout▪ Frame Layout▪ TabHost*
Can launch other Activities, Services & Broadcast Events
Built using XML, code or Both Supports Styles, Themes, Localization etc.
6
Android Services
Services are processes that run in the background.
Not much unlike a windows service. Can be used to play music, communicate
with a server, perform long running processes etc.
Typically used to trigger notifications in the status bar.
Communication (IPC) can be done using AIDL – Android Interface Definition Language.
7
Broadcast Receivers
Receive and react to broadcast announcements from the OS
No UI, but they may trigger an Activity
Examples: Time-zone has changed Battery is low Picture has been taken User has changed a system
preference
8
Content Providers
Provide clean way for your application to expose its data to other applications on the device and visa versa.
Data can be stored in any way you want, Files, Preferences, SQL Lite DB or whatever other resource you need.
Content can be audio, video, images, contact information, etc.
9
Home Screen Widgets
A small “slice” of an application that runs on the application home screen.
Limited functionality & set of Views/Layouts can be used.
Good for displaying things like stock tickers, status updates, weather forecasts, news headlines, etc.
Allows users to see a key piece of your app, without having to leave their home screen.
10
Killer Development Environment
What you’ll need to create Android Apps: Java Development Kit (JDK) 6 Eclipse▪ Spring Tool Suite with Google (
http://www.springsource.com/products/springsource-google-download
)▪ Eclipse Classic 3.5 or greater will also work
Android SDK Android Development Tools (ADT) – eclipse
plug-in for Android development.
11
Creating an Android Project in Eclipse File New Android Project
12
Project Structure
• Source Code Directory• UI Layout Directory (XML) – validated by compiler w/ detailed error
messages• Application Manifest – tells OS how to interact w/ your app.• Icons / Graphics – can be bitmap or xml based• Strings / Styles / Themes
13
The Flow of an Activity
14
Demo time
Lets build a calculator!
15
Resources
Main Android Dev Site: http://developer.android.com
Stack overflow: http://stackoverflow.com/questions/tagged/android
Google I/O Talks: http://www.youtube.com/googledevelopers
Tutorials & Forums: http://www.anddev.org/ http://www.androidpeople.com/ http://www.androidcentral.com/
Building Android Apps with Hudson & Ant: http://www.facebook.com/note.php?note_id=499519
075367