android quick talk

66
Android – Quick Talk

Upload: senthil-kumar

Post on 30-Oct-2014

184 views

Category:

Software


1 download

DESCRIPTION

Android quick talk

TRANSCRIPT

Page 1: Android quick talk

Android – Quick Talk

Page 2: Android quick talk

In the past:

Today:

Entertainment purpose

Substantial purchase criteria

Apps on the Device

Page 3: Android quick talk

Agenda•Mobile Application Development (MAD)•Intro to Android platform•Platform architecture•Application building blocks•Development tools•Hello Android

Page 4: Android quick talk

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!

Page 5: Android quick talk

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

Page 6: Android quick talk

Android Phones…

Page 7: Android quick talk

Android Tablets…Android Devices

Page 8: Android quick talk

Android-Powered TV

Page 9: Android quick talk

Android-Powered Microwave

Page 10: Android quick talk

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

Page 11: Android quick talk

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

Page 12: Android quick talk

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+

Page 13: Android quick talk

Distribution of Devices

Data collected during a 14-day period ending on January 3, 2012

http://developer.android.com/resources/dashboard/platform-versions.html

Page 14: Android quick talk

The Android Developer Website•http://developer.android.com

•This could be your homepage from now on…

Page 15: Android quick talk

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

Page 16: Android quick talk

Open Handset Alliance- a consortium of several companies

Page 17: Android quick talk

Open Handset Alliance - Many more joined

A business alliance consisting of 47 companies to develop open standards for mobile devices

Page 18: Android quick talk

Android FeaturesReuse and replacement of componentsDalvik virtual machineIntegrated browserOptimized graphicsSQLiteMedia supportGSM TelephonyBluetooth, EDGE, 3G, and WiFiCamera, GPS, compass, and accelerometerRich development environment

Page 19: Android quick talk

http://code.google.com/android/goodies/index.html

Well, sort of…

Android makes mobile Java easier!!

Page 20: Android quick talk

Android System Architecture

Page 21: Android quick talk

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

Page 22: Android quick talk

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

Page 23: Android quick talk

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

Page 24: Android quick talk

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.

Page 25: Android quick talk

Applications

•Applications and Widgets: the real programs display information and interact with users.

•Built in and user apps•Can replace built in apps

Page 26: Android quick talk

Application Building Blocks•Activity•IntentReceiver•Service•ContentProvider

Page 27: Android quick talk

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.

Page 28: Android quick talk

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

Page 29: Android quick talk

Intent Receivers•Components that respond to broadcast

‘Intents’•Way to respond to external notification or

alarms•Apps can invent and broadcast their own

Intent

Page 30: Android quick talk

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.

Page 31: Android quick talk

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

Page 32: Android quick talk

Services•Faceless components that run in the

background▫E.g. music player, network download etc…

Page 33: Android quick talk

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.

Page 34: Android quick talk

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

Page 35: Android quick talk

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!

Page 36: Android quick talk

Development process for an Android app

Page 37: Android quick talk

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

Page 38: Android quick talk

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

Page 39: Android quick talk

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

Page 40: Android quick talk

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

Page 41: Android quick talk

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.

Page 42: Android quick talk

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!

Page 43: Android quick talk

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

Page 44: Android quick talk

“Hello, Android”

Page 45: Android quick talk

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

Page 46: Android quick talk

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)

Page 47: Android quick talk

2. Create an Android Project in Eclipse File → New → Project

Select “Android Project”

Fill in Project details...

Page 48: Android quick talk

Name that appearson device

Directoryname

Class toautomatically

create

Java package

Androidversion

Page 49: Android quick talk

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

Page 50: Android quick talk

Hello World…

Page 51: Android quick talk

Sourcecode

Auto-generatedcode

UIlayout

Stringconstants

Configuration

Page 52: Android quick talk

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

Page 53: Android quick talk

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

Page 54: Android quick talk

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

Page 55: Android quick talk

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

Page 56: Android quick talk

New Mobile Industry!•Mobile Payment•Mobile Advertisement•Location Based Service•And the usual Mobile…Voice, Text and Data

Page 57: Android quick talk

Easy to use

Design

All-in-one-solutions

Appstore

Additionalsoftware

No bugsHigh-class products

Good performance

Page 58: Android quick talk

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

Page 59: Android quick talk

Backup Slides

Page 60: Android quick talk

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

Page 61: Android quick talk

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

Page 62: Android quick talk

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

Page 63: Android quick talk

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

Page 64: Android quick talk

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

Page 65: Android quick talk

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

Page 66: Android quick talk

Building and Running Android Apps