2. Apps on the Device
In the past:
Today:
Entertainment purpose
Substantial purchase criteria
3. Agenda
ā¢ Mobile Application Development (MAD)
ā¢ Intro to Android platform
ā¢ Platform architecture
ā¢ Application building blocks
ā¢ Development tools
ā¢ Hello Android
4. Why MAD? (Mobile App Development)
ā¢ The fact that we can!
ā¢ Mobile platform is the platform of the future
ā« Double-digit growth in world-wide smartphone ownership3
ā¢ Smart Phones
ā¢ Internet access anywhere
ā¢ Social networking
ā¢ Millions of mobile users
ā¢ Open standards
ā¢ Job market is hot
ā« Market for mobile software surges from $4.1 billion in 2009 to
$17.5 billion by 20121
ā« 2010 Dice.com survey: 72% of recruiters looking for iPhone
app developers, 60% for Android
ā¢ Students (and faculty!) are naturally interested!
5. Why Android?
ā¢ A lot of students have them
ā« 2010 survey: 22% of college students have Android phone (26%
Blackberry, 40% iPhone)
ā« Gartner survey: Android used on 22.7% of smartphones sold world-wide
in 2010 (37.6% Symbian, 15.7% iOS)
ā¢ Students already know Java and Eclipse
ā« Low learning curve
ā« Students can use App Inventor for Android
ā¢ Transferring app to phone is trivial
ā« Can distribute by putting it on the web
ā« Android Market for wider distribution
ā¢ Itās not 1984
10. Brief History
ā¢ 1996
ā« The WWW already had websites with color and images, but, the best
phones displayed a couple of lines of monochrome text!
ā« Enter: Wireless Application Protocol and Markup Language
WAP : Stripped down bandwidth reduction
WML : Stripped down HTML for content
Many issues (WAP = āWait And Payā)
Few developers to produce content (it wasnāt fun!)
ā« Really hard to type in URLs using the small keyboards
ā« Data fees frightfully expensive
ā« No billing mechanism ā content difficult to monetize
ā¢ Other platforms emerged
ā« Palm OS, Blackberry OS, J2ME, Symbian (Nokia), BREW, OS X
iPhone, Windows Mobile
11. Brief History - Android
ā¢ 2005
ā« Google acquires startup
Android Inc. to start Android
platform
ā« Work on Dalvik VM begins
ā¢ 2007
ā« Open Handset Alliance
formed to develop open
standards for mobile devices
ā« Early look at SDK
ā¢ 2008
ā« Google sponsors 1st Android
Developer Challenge
ā« T-Mobile G1 announced
ā« SDK 1.0 released
ā« Android released open source
(Apache License)
ā« Android Dev Phone 1 released
ā« Android Source code
Published
ā¢ 2009
ā« SDK 1.5 (Cupcake)
New soft keyboard with
āautocompleteā feature
ā« SDK 1.6 (Donut)
Support Wide VGA
ā« SDK 2.0/2.0.1/2.1 (Eclair)
Revamped UI, Browser
ā¢ 2010
ā« Nexus One released to the
public
ā« SDK 2.2 (Froyo)
Flash support, Tethering
ā« SDK 2.3 (Gingerbread)
UI update, system-wide
copy-paste
12. Brief History - Android
Honeycomb
Android 3.0-3.2
ā¢ 2011
ā« SDK 3.0/3.1/3.2 (Honeycomb) for tablets only
Ice cream Sandwich
New UI for tablets, support multi-core processors
SDK 4.0/4.0.1/4.0.2/4.0.3 (Ice Cream Sandwich)
Changes to the UI, Voice input, NFC
Android 4.0+
13. Distribution of Devices
Data collected during a 14-day period ending on January 3, 2012
http://developer.android.com/resources/dashboard/platform-versions.html
14. The Android Developer Website
ā¢ http://developer.android.com
ā¢ This could be your homepage from now onā¦
15. What is Android?
ā¢ A software stack for mobile devices that includes
ā« An operating system
ā« Middleware
ā« Key Applications
ā¢ Uses Linux to provide core system services
ā« Security
ā« Memory management
ā« Process management
ā« Power management
ā« Hardware drivers
ā¢ Android Apps are written in Java
ā¢ Open Source with an Apache License
ā¢ An Open Handset Alliance Project
17. Open Handset Alliance - Many more joined
A business alliance consisting of
47 companies to develop
open standards for mobile
devices
18. Android Features
Reuse and replacement of components
Dalvik virtual machine
Integrated browser
Optimized graphics
SQLite
Media support
GSM Telephony
Bluetooth, EDGE, 3G, and WiFi
Camera, GPS, compass, and accelerometer
Rich development environment
19. Android makes mobile Java easier!!
Well, sort ofā¦
http://code.google.com/android/goodies/index.html
21. Linux Kernel
ā¢ Relying on Linux Kernel 2.6 for core system services
ā« Memory and Process Management
ā« Network Stack
ā« Driver Model
ā« Security
ā« And other operating system services
ā¢ Providing an abstraction layer between the H/W and
the rest of the S/W stack
22. Libraries
ā¢ C/C++ libraries
ā¢ Interface through Java
ā¢ Surface manager ā Handling UI Windows
ā¢ 2D and 3D graphics
ā¢ Media codecs, SQLite, Browser engine, etc
ā¢ Only to be called by higher level programs
23. Android Runtime
ā¢ Dalvik VM (Executes .dex)
ā¢ Providing environment on which
every Android application runs
ā¢ Each Android application runs in
its own process, with its own
instance of the Dalvik VM.
ā¢ Device can run multiple VMs
efficiently.
ā¢ Register-based virtual machine Dex
files
ā¢ Compact and efficient than
class files
ā¢ Limited memory and battery
power
ā¢ .dex format is optimized for
minimal memory footprint.
ā¢ Not J2SE/J2ME
ā¢ Core Libraries
ā Providing most of the
functionality available in the core
libraries of the Java language
ā APIs
ā Data Structures
ā Utilities
ā File Access
ā Network Access
ā Graphics, Etc
24. Application Framework
ā¢ API interface
ā¢ View System - Used to build an application, including lists, grids, text
boxes, buttons, and embedded web browser
ā¢ Content Provider - Enabling applications to access data from other
applications or to share their own data
ā¢ Resource Manager - Providing access to non-code resources (localized strings,
graphics, and layout files)
ā¢ Notification Manager - Enabling all applications to display customer alerts in the
status bar
ā¢ Activity Manager - Managing the lifecycle of applications and providing a common
navigation backstack
ā¢ Enabling and simplifying the reuse of components
ā« Developers have full access to the same framework APIs used by the core applications.
ā« Users are allowed to replace components.
25. Applications
ā¢ Applications and Widgets: the real programs display
information and interact with users.
ā¢ Built in and user apps
ā¢ Can replace built in apps
27. Activities
ā¢ Typically correspond to one UI screen
ā¢ But, they can:
ā« Be faceless
ā« Be in a floating window
ā« Return a value
ā¢ Each user interface screen is represented by an
Activity class.
ā¢ Each activity has its own life cycle.
ā¢ Activity uses Intent object to jump between them.
28. Life cycle of an Activity Application run in their own
processes (VM, PID)
Processes are started and
stopped as needed to run an
application's components
Processes may be killed to
reclaim resources
29. Intent Receivers
ā¢ Components that respond to broadcast āIntentsā
ā¢ Way to respond to external notification or alarms
ā¢ Apps can invent and broadcast their own Intent
30. Intents
ā¢ Think of Intents as a verb and object; a description of
what you want done
ā« E.g. VIEW, CALL, PLAY etc..
ā¢ Intent provides late running binding to other apps
ā¢ Intent activates activities, services, and broadcast
receivers.
ā¢ Intent can be used in explicit way or implicit way.
ā¢ System matches Intent with Activity that can best
provide the service
ā¢ Activities and IntentReceivers describe what Intents they
can service
ā¢ When launch a intent object, framework will match and
find the qualified components and leave them for users
to choose which to run.
31. Intents
Home
Contacts
GMail
Chat
Blogger
āPick photoā
Picasa
Photo
Gallery
Client component makes a
request for a specific action
System picks best
Ncoemw pconmepnot nfoern ttsh acat na cutisoen
existing functionality Blogger
32. Services
ā¢ Faceless components that run in the background
ā« E.g. music player, network download etcā¦
33. ContentProviders
ā¢ Enables sharing of data across applications
ā« E.g. address book, photo gallery
ā¢ Client+server architecture
ā¢ Provides uniform APIs for:
ā« querying
ā« delete, update and insert.
ā¢ Content is represented by URI and MIME type
ā¢ Content Resolver provides API interface for
applications.
ā¢ Content Providers is the server managing the DB
tables and database content with different
application.
34. Security and permissions
ā¢ Security in Android follows standard Linux
guidelines
ā¢ Each application runs in its own process
ā¢ Application can't disrupt other applications, except
by explicitly declaring the permissions it
ā¢ Finer grained permissions are then granted (revoked)
per operations
ā¢ Each Android package is given its own unique Linux
user ID
35. Developing apps
ā¢ What are they?
ā« Any application that runs on a mobile device
ā¢ Types
ā« Web apps: run in a web browser
ā« HTML, JavaScript, Flash, server-side components, etc.
ā¢ Native - Compiled binaries for the device
ā¢ Often make use of web services
ā¢ Because of the apps, Smartphone(s) become smart!
37. Android Apps
ā¢ Built using Java and new SDK libraries
ā« No support for some Java libraries like Swing & AWT
ā« Oracle currently suing Google over use
ā¢ Java code compiled into Dalvik byte code (.dex)
ā« Optimized for mobile devices (better memory management, battery
utilization, etc.)
ā¢ Dalvik VM runs .dex files
38. Applications Are Boxed
ā¢ By default, each app is run in its own
Linux process
ā« Process started when appās code needs to
be executed
ā« Threads can be started to handle time-consuming
operations
ā¢ Each process has its own Dalvik VM
ā¢ By default, each app is assigned unique
Linux ID
ā« Permissions are set so appās files are only
visible to that app
39. Android Design Philosophy
ā¢ Applications should be:
ā« Fast
Resource constraints: <200MB RAM, slow processor
ā« Responsive
Apps must respond to user actions within 5 seconds
ā« Secure
Apps declare permissions in manifest
ā« Seamless
Usability is key, persist data, suspend services
Android kills processes in background as needed
40. Leveraging the web
ā¢ To keep your apps fast and responsive, consider how
you can leverage the web
ā« What ____________ can be ________ on a server
or in the cloud?
Tasks/performed
Data/persisted
Data/retrieved
ā« Beware, data transfer is also expensive and can be slow
41. Challenges
ā¢ CPU typically runs 500-600 Mhz
ā¢ RAM available to an App may only
be a few megabytes
ā¢ Disk (flash) access is very slow
ā¢ Lifecycle - apps must pause/quit
often, and restore to give the
illusion that they are always
running
ā¢ UI design
ā¢ typical screen may be HVGA
(320x480)
ā¢ may be in portrait or landscape
ā¢ very high DPI - small text may not
be readable
ā¢ touch resolution is very low (~25
pixel)
ā¢ Network access may be slow and
(very) intermittent
ā¢ Fragmentation of Hardware
ā« Different screen resolutions
ā« Different screen sizes
ā« Different hardware keys
ā« Different input methods
ā¢ Some have a phone, some not...
ā« Some have GPS, some not...
ā« Some have 3G, some not...
ā« Some have a cam, some not...
ā« Some are good, some not...
ā« Some are not even phonesā¦
ā¢ Hardware diversification will
continue to be harder and harder.
42. Opportunities
ā¢ 100s of millions of mobile phone users
ā¢ Very high growth, esp. in Asia
ā¢ "Wild wild west" of application development
ā¢ think 1985 on the desktop (if you were born by then)
ā¢ no dominant 3rd party developers.... yet
ā¢ what will the killer app categories be?
ā¢ what does it mean to have any app + the internet in
your pocket?
ā¢ You can develop for it today!
43. Learning
ā¢ Reinforce the basics: OOP, decomposition, etc.
ā¢ Separation of UI design and functionality
ā¢ XML and resource files
ā¢ Events and Listeners
ā¢ Callback methods
ā¢ Threads
ā¢ Application of already learnt
ā« Java!
Inheritance, method overriding
Interfaces, Casting
Exceptions
Debugging
Reading API documentation
ā« Eclipse
Easy to pick up quickly, though
45. Creating Your First(?) Android App
ā¢ Set up your development environment
ā¢ Create a new Android project in Eclipse
ā¢ Run it in the emulator
ā¢ Debug ensues
ā¢ http://developer.android.com/guide/tutorials/hello-world.
html
46. 1. Set Up Your Android Environment
ā¢ http://developer.android.com/sdk
ā¢ Install Eclipse
ā¢ Install Android SDK (Android libraries)
ā¢ Install ADT plugin (Android development tools)
ā¢ Create AVD (Android virtual device)
47. 2. Create an Android Project in Eclipse
ļ¬ File ā New ā Project
ļ¬ Select āAndroid Projectā
ļ¬ Fill in Project details...
48. Name that appears
on device
Directory
name
Class to
automatically
create
Java package
Android
version
49. 3. Run the Android Application
ļ¬ Run ā Run (or click the āRunā button)
ļ¬ Select āAndroid Applicationā
ļ¬ The emulator may take a few minutes to start, so be
patient!
ļ¬ You don't need to restart the emulator when you
have a new version of your application
52. HelloAndroid.java
1 public class HelloAndroid extends Activity {
2 /** Called when the activity is first created. */
3 @Override
4 public void onCreate(Bundle savedInstanceState)
5 {
6 super.onCreate(savedInstanceState);
7 setContentView(R.layout.main);
8 }
9 }
56. New Mobile Industry!
ā¢ Mobile Payment
ā¢ Mobile Advertisement
ā¢ Location Based Service
ā¢ And the usual Mobileā¦Voice, Text and Data
57. Easy to use
Design
All-in-one-solutions
Appstore
Additional
software
No bugs High-class products
Good performance
58. Summary
ā¢ New world of Possibilitiesā¦
ā¢ Android seems to be the future of
mobile OS's and mobile software
development.
ā¢ Android just add fun in making
phones cooler and development easier.
ā¢ Android could easily move its way into
the market from phones to
notebooks and desktops
ā¢ After 2013, Android will dominate the
app market
60. Mobile Devices: Advantages
(as compared to fixed devices)
ā¢ Always with the user
ā¢ Typically have Internet access
ā¢ Typically GPS enabled
ā¢ Typically have accelerometer & compass
ā¢ Most have cameras & microphones
ā¢ Many apps are free or low-cost
61. Mobile Devices: Disadvantages
ā¢ Limited screen size
ā¢ Limited battery life
ā¢ Limited processor speed
ā¢ Limited and sometimes slow network access
ā¢ Limited or awkward input: soft keyboard, phone
keypad, touch screen, or stylus
ā¢ Limited web browser functionality
ā¢ Range of platforms & configurations across devices
62. Mobile Applications
ā¢ What are they?
ā« Any application that runs on a mobile device
ā¢ Types
ā« Web apps: run in a web browser
HTML, JavaScript, Flash, server-side components, etc.
ā« Native: compiled binaries for the device
Often make use of web services
63. Platform Highlights
ā¢ The Android platform introduces many features for
users and developers ā Making Android even better
ā¢ Performance Improvements
ā¢ Faster Camera start-up and image capture
ā¢ Much faster acquisition of GPS location (powered by
SUPL AGPS)
ā¢ Smoother page scrolling in Browser
ā¢ Speedier GMail conversation list scrolling
64. Platform Highlights
ā¢ On-screen soft keyboard
ā« Works in both portrait and landscape orientation
ā« Support for user installation of 3rd party keyboards
ā« User dictionary for custom words
ā¢ Home screen
ā« Widgets
Bundled home screen widgets include: analog clock, calendar, music
player, picture frame, and search
ā« Live folders
ā¢ Camera & Gallery
ā¢ Video recording
ā¢ Video playback (MPEG-4 & 3GP formats)
ā¢ Bluetooth
ā« Stereo Bluetooth support (A2DP and AVCRP profiles)
ā« Auto-pairing
ā« Improved hands free experience
65. Platform Highlights
ā¢ Browser
ā« Updated with latest Webkit browser
JavaScript engines
ā« Copy 'n paste in browser
ā« Search within a page
ā« User-selectable text-encoding
ā¢ UI changes include:
ā« Unified Go and Search box
ā« Tabbed bookmarks/history/most-visited
screen
ā¢ Contacts
ā« Shows user picture for Favorites
ā« Specific date/time stamp for events in call
log
ā« One-touch access to a contact card
from call log event
ā¢ System
ā« New Linux kernel
ā« SD card file system auto-checking and
repair
ā¢ SIM Application Toolkit 1.0
ā¢ Google applications (Android SDK)
ā« View Google Talk friends' status in Contacts,
SMS, MMS, GMail, and Email applications
ā« Batch actions such as archive, delete, and
label on Gmail messages
ā« Upload videos to YouTube
ā« Upload photos on Picasa