android quick talk
Post on 30-Oct-2014
184 Views
Preview:
DESCRIPTION
TRANSCRIPT
Android – Quick Talk
In the past:
Today:
Entertainment purpose
Substantial purchase criteria
Apps on the Device
Agenda•Mobile Application Development (MAD)•Intro to Android platform•Platform architecture•Application building blocks•Development tools•Hello Android
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!
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
Android Phones…
Android Tablets…Android Devices
Android-Powered TV
Android-Powered Microwave
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
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
Brief History - Android
•2011▫SDK 3.0/3.1/3.2 (Honeycomb) for tablets only
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
HoneycombAndroid 3.0-3.2
Ice cream SandwichAndroid 4.0+
Distribution of Devices
Data collected during a 14-day period ending on January 3, 2012
http://developer.android.com/resources/dashboard/platform-versions.html
The Android Developer Website•http://developer.android.com
•This could be your homepage from now on…
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
Open Handset Alliance- a consortium of several companies
Open Handset Alliance - Many more joined
A business alliance consisting of 47 companies to develop open standards for mobile devices
Android FeaturesReuse and replacement of componentsDalvik virtual machineIntegrated browserOptimized graphicsSQLiteMedia supportGSM TelephonyBluetooth, EDGE, 3G, and WiFiCamera, GPS, compass, and accelerometerRich development environment
http://code.google.com/android/goodies/index.html
Well, sort of…
Android makes mobile Java easier!!
Android System Architecture
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
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
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
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.
Applications
•Applications and Widgets: the real programs display information and interact with users.
•Built in and user apps•Can replace built in apps
Application Building Blocks•Activity•IntentReceiver•Service•ContentProvider
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.
Life cycle of an ActivityApplication run in their own processes (VM, PID)Processes are started and stopped as needed to run an application's componentsProcesses may be killed to reclaim resources
Intent Receivers•Components that respond to broadcast
‘Intents’•Way to respond to external notification or
alarms•Apps can invent and broadcast their own
Intent
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.
Intents
GMail
Contacts
Home
Blogger
ChatClient component makes a request for a specific action
“Pick photo”
Picasa
System picks best component for that actionNew components can use existing functionality
Blogger
Photo Gallery
Services•Faceless components that run in the
background▫E.g. music player, network download etc…
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.
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
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!
Development process for an Android app
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
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
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
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
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.
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!
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
“Hello, Android”
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
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)
2. Create an Android Project in Eclipse File → New → Project
Select “Android Project”
Fill in Project details...
Name that appearson device
Directoryname
Class toautomatically
create
Java package
Androidversion
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
Hello World…
Sourcecode
Auto-generatedcode
UIlayout
Stringconstants
Configuration
1 public class HelloAndroid extends Activity {2 /** Called when the activity is first created. */3 @Override4 public void onCreate(Bundle savedInstanceState) 5 {6 super.onCreate(savedInstanceState);7 setContentView(R.layout.main);8 }9 }
HelloAndroid.java
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 android:orientation="vertical" 5 android:layout_width="fill_parent" 6 android:layout_height="fill_parent" 7 > 8 <TextView 9 android:layout_width="fill_parent" 10 android:layout_height="wrap_content" 11 android:text="@string/hello "12 />13 </LinearLayout>
main.xml
1 <?xml version="1.0" encoding="utf-8"?>2 <resources>3 <string name="hello">Hello World, HelloAndroid!4 </string>5 <string name="app_name">Hello, Android</string>6 </resources>
strings.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <manifest 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 package="edu.upenn.cis542" 5 android:versionCode="1" 6 android:versionName="1.0"> 7 <application android:icon="@drawable/icon" 8 android:label="@string/app_name"> 9 <activity android:name=".HelloAndroid"10 android:label="@string/app_name">11 <intent-filter>12 <action 13 android:name="android.intent.action.MAIN" />14 <category 15 android:name="android.intent.category.LAUNCHER"/>16 </intent-filter>17 </activity>18 </application>19 </manifest>
AndroidManifest.xml
New Mobile Industry!•Mobile Payment•Mobile Advertisement•Location Based Service•And the usual Mobile…Voice, Text and Data
Easy to use
Design
All-in-one-solutions
Appstore
Additionalsoftware
No bugsHigh-class products
Good performance
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
Backup Slides
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
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
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
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
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
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
Building and Running Android Apps
top related