android application development introduction€¦ · android application development introduction...
TRANSCRIPT
Android Application Development Introduction
August 2, 2010
Presented By W. David Taylor
Part 1 - Intro To Android
What is Android Exactly?
Android is a software stack for mobile devices that includes an operating system (linux), middleware and key applications. The Android SDK provides the tools and APIs necessary to begin
developing applications on the Android platform using the Java programming language.
API Highlights
The Android API provides access to hardware resources
● Camera● GPS● Accelerometer● Compass● SD Card File System
API Highlights (cont.)
The Android API provides access to Software Resources
● Google Maps● Geocoding● Location Based Services● Media Player● Phone Dialer
API Highlights (cont.)
The Android API sports many advanced programming features
● Background Services● SQLite Database for Data Storage and Retrieval.● Shared Data and Interapplication Communications
Application Architecture
The Android application architecture encourages component reuse of activities, services, data with other applications
● Activity Manager – Manages the life cycle of activities● Views – Used to construct user interfaces (buttons, textviews,
etc.)● Notification Manager – Mechanism to signal users● Content Providers – Used to share you application's data● Resource Manager – Used to manage non-source resources
like strings and graphics
Dalvik Virtual Machine
Each Android application runs in it's own instance of the Dalvik Virtual Machines (named after a fishing village in Iceland).
The Dalvik VM is a register-based VM that's been optimized to ensure that a device can run multiple instances efficiently.
Programming Environment
The Android SDK (Software Development Kit) and AVD (Android Virtual Device) emulator are nicely integrated with Eclipse IDE.
Eclipse and Android are free and run on Linux, Windows, and Apple OS X. A Java VM is required on the Development Machine.
Eclipse and Android
Resources
Android employs static resource files that can be accessed from code to help streamline application development
● Drawable – used to store images and xml drawable definitions
● Layouts - used for interface design● Values – used to store strings and other
variable values
Layout Types
Android supports the following layout types
● FrameLayout – A blank space where child objects can be arranged
● LinearLayouts - aligns all children in a single direction — vertically or horizontally
● TableLayout – positions its children into rows and columns● RelativeLayout - lets child views specify their position relative
to the parent view or to each other
Linear Layout Example
Simple Linear Layout
Android Activities
Activities are the application's presentation layer. Every screen extends the base Activity class. Activities use Views (controls) to build user interfaces.
Part 2 – Real World Android Project
Let's Look at a Real Project
To Demonstrate some of the capabilities of Android let's look at a project that I am developing. The application allows users to add notes to Goolge Maps based on user's location.
This Project uses Native GPS, Internet, and Goolge Maps.
Map Crumbz (My Learning Project)
Splash Screen● Uses built in Progress Dialog
API● Uses GPS API to get actual
location● Uses a Thread to proceed to
main screen after a location fix is obtained
Map Crumbz (Cont.)
Main Map Screen● Uses Google MapView API● Uses Frame Layout with child
TableView (top bar) and MapView
● Uses Drawable Resource for Map Icon
Map Crumbz (Cont.)
Main Screen Menus● Uses Menu xml resources to
define menu items● Menu's are created by
overriding the onCreateOptionsMenu() Function in the Activity Class
● Menu item selections are handled by overriding the OnOptionsItemsSelection() Function in the Activity Class
Map Crumbz (Cont.)
Main Screen Satellite View● Calls the Google MapView API
to switch to Satellite Background
● To Do! Make marker lighter to show up better when in Satellite View
Map Crumbz (Cont.)
Enter Map Crumb● When the button is pressed
the Map Activity invokes a sub-activity and bundles data to pass in by calling the StartActivityForResult() function
● The calling Map Activity listens for a result by overriding the OnActivityResult() function
Map Crumbz (Cont.)
Data Entry Screen● Uses FrameLayout with child
TableLayouts with a ScrollView
● Notice that the Lat and Lon where passed in by the Map Activity
Map Crumbz (Cont.)
Geocoding the Location● Calling the Geocoding API
obtain the location's address
● Notice this returns more than one result
● Geocoding is not an exact science
● Use with caution
Map Crumbz (Cont.)
Enter Crumb Data● Fill in the data fields via the
software keyboard● When the Add Crumb button
is pressed the data is added to a SQLite database table and the activity returns to the main calling Map Activity
Map Crumbz (Cont.)
Mission Accomplished● Now the Map Activity shows
the Map Crumb that was just entered
● The Map Activity queries the SQLite database and adds all Map Crumbz in the database to the map
Map Crumbz (Cont.)
Recalling the Data● The MapView API exposes
an onTap() function that allows you to get data for the Tapped item
● The data is displayed in a custom Dialog that raises an Intent (event) callback based on the button pressed
Map Crumbz (Cont.)
Built in MapView zoom controls● The MapView allows you the option of
toggling built in zoom controls● Please Note the other Map Crumbz
on the Map
Part 3 – References
Current Android Books
Online API Documentation
http://developer.android.com
Current Devices Running Android
● Mobile Phones● Slates like the iPad● Google TV
Thanks for Attending!