android development: the 20,000-foot view

47
 Copyright © 2013 CommonsWare, LLC Android Development... The 20,000-Foot View

Upload: commonsware

Post on 08-Sep-2014

688 views

Category:

Sports


0 download

DESCRIPTION

from the October 203 LVTech Meetup

TRANSCRIPT

Page 1: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Android Development...The 20,000-Foot

View

Page 2: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Welcome to Android!

● Traditional Development Model– Java, XML, and other good stuff

● Alternative Development Models– Other languages– Native development– HTML5 and hybrid apps– Games– Other cross-platform options

Page 3: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Basket of Components

● Activity– Primary unit of user interface– Think: screen, page, window– “User transaction”

Page 4: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Basket of Components

● Service– Long-running task (download)– User-controlled background task (music player)– “Cron job” (check for unread email)– Integration point (third-party API)

Page 5: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Basket of Components

● Broadcast Receiver– System events (battery low)– Application messages

● Content Provider– Integration point (expose database)– Abstraction layer (hide database internally)

Page 6: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Activities, Fragments, & Widgets

● Activities Host Widgets– Widget = micro unit of UI– Organized via layout managers– Described using XML

● Activity as a whole● Portions of an activity (rows in a selection list)

Page 7: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Activities, Fragments, & Widgets

● Fragments Manage Widgets– Reuse for multiple screen sizes– Reuse for multiple instances

● Horizontal swiping strategies

Page 8: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Activities, Fragments, & Widgets

● Multiple Layout Flavors– Portrait versus landscape– Normal versus large– Touchscreen versus pointer (trackball)

● Flow = Web-Like– Click to launch new activities– BACK button– HOME button

Page 9: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Java and Dalvik

● What You Write– Java– XML– C/C++ (optional)

Page 10: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Java and Dalvik

● What Android Runs: Dalvik– Virtual machine, like Perl or Java– Build tools translate your Java code to Dalvik

bytecode– Usually invisible to you

Page 11: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Resources

● Non-Java Application Assets– Layouts– Images (PNG, JPEG, etc.)– Audio clips– Strings– Animations– Menus– Etc.

Page 12: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Resources

● Resource Sets– Language– Screen density– Screen size– Dozens of other criteria

Page 13: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Tools

● Eclipse...– Android Developer Tools plugin– GUI preview mode

Page 14: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Tools

● ...or Android Studio...– New IDE, based on IntelliJ IDEA, under

development at Google– “Early access preview” available today

● Broken enough that is mostly for seasoned Android developers

– Should be the long-term focus

Page 15: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Tools

● ...Or Not– IntelliJ IDEA– NetBeans– No particular IDE

● Platforms– Linux– OS X– Windows

Page 16: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Demo: Hello, World

Page 17: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Intents and Integration

● Intents as Message Bus– Start an activity– Start a service– Send a broadcast

Page 18: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Intents and Integration

● Use Intents Internally– Start your own activities– Start your own services– Send your own “narrowcasts”

● Service activity or notification→

– Send your own “broadcasts” to third parties

Page 19: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Intents and Integration

● Use Intents Externally– Send a message with the user's choice of “send”

application (email? SMS? Twitter? Facebook?)– Offer to view a certain MIME type– Launch an OS-supplied activity (map)– Launch a third-party activity– Implement a plug-in system

Page 20: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

The Manifest

● AndroidManifest.xml, in project root● Table of contents● Additional metadata

– App and OS versions– Requested and required permissions– Supported screen sizes

Page 21: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Notable OS Features

● Data Stores– SQLite: relational database engine, in-process– Files

● Internal: not accessible by user● External: accessible by user via mounting device

– Shared Preferences● Mostly for user settings● GUI framework for collecting these

Page 22: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Notable OS Features

● Notifications– Put icon in status bar (phones) or system bar

(tablets) or elsewhere (TVs)– Optional hardware alerts

● Ringtone, vibration, etc.

– Designed to let user know of work being done in the background

Page 23: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Notable OS Features

● Multimedia– Audio, video

● Decent but not infinite roster of formats/codecs● Some codecs are commercial, may not always be

present

– Recording, playback– Local, streaming

Page 24: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Notable OS Features

● Locations– GPS– WiFi hotspot proximity– Cell tower triangulation

● Maps– Google Maps– Third-party mapping engines

Page 25: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Notable OS Features

● Sensors– Accelerometer– Gyroscope– Orientation– Ambient Light– Barometric Pressure– Etc.

Page 26: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Notable OS Features

● Other Hardware– Telephony– WiFi– Bluetooth– NFC– Cameras– USB

Page 27: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Production

● APK File– Android “executable”– Digitally signed (self-signed certificate)– Freely distributable

● Not limited to Android Market or any other single venue

Page 28: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Production

● Play Store– $25 setup fee– Upload and go

● Available on many devices within hours of release

● Other Markets Available– Example: Amazon Appstore for Android

● Self-Distribution

Page 29: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

But, What If I Hate Java?

Page 30: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Varying Definitions of ”Native”

● Native = C/C++– In comparison to Java

● Native = Java– In comparison to HTML5 and hybrid apps

Page 31: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Native C/C++ Development

● Native Development Kit (NDK)– Allows you to write C/C++ libraries, link into your

Android app● Pros

– Speed– Possible reuse across platforms

Page 32: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Native C/C++ Development

● Cons– CPU architectures (x86 vs. ARM vs. MIPS)– May not like C/C++ any more than Java

● Pattern #1: Extension Library– Migrate select algorithms into native code– Examples: image processing, signal processing,

game AI

Page 33: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Native C/C++ Development

● Pattern #2: Complete App– Eschew all trappings of traditional apps– Mostly for OpenGL/OpenSL games

Page 34: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

HTML5 Web Apps

● Traditional Web development, writ small● Key: Cache Manifest

– Designate files that should be cached, beyond standard ephemeral cache

– Objective: Allow app to be run offline● Other Facets of HTML5 Specification

– Storage, WebSockets, video, camera, location tracking, etc.

Page 35: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

HTML5 Web Apps

● Pros– May already have Web development talent– Cross-platform

● Cons– Need touch-aware coding/libraries– Discoverability an issue

● Play Store does not list Web apps● Amazon Appstore for Android does

Page 36: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Hybrid Apps

● HTML5 UI on a (Java) Native Foundation– Package up HTML/CSS/JS/images into APK– Gives you access to APIs beyond HTML5 specs

● Most Popular: PhoneGap– Adobe product, based on Apache Cordova– Cross-platform– Optional hosted build service

Page 37: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Hybrid Apps

● Pros– Closer to native apps for distribution and

capability● Cons

– Not a native UI● Big or small problem depending upon audience

– Cannot do everything that a native app can

Page 38: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Game Engines

● Android-Specific– AndEngine, Box2D

● Cross-Platform– Unity 3D, Cocos 2D, Corona, Havok, libGDX,

Proton● Dozens of others

Page 39: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Other Cross-Platform Options

● Titanium Mobile– Develop in JavaScript, but manipulating native

widgets (not HTML)● Adobe AIR

– Well, OK, sorta cross-platform...● Xamarin

– .NET for Android (MonoDroid)

Page 40: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Other Cross-Platform Options

● Sencha– Offers own PhoneGap-style hybrid engine for

use with Sencha Touch-based apps● MoSync

– Another take on hybrid app engine● Rhodes

– Web apps, but with Ruby “server”

Page 41: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

App Inventor

● Drag-and-Drop– UI– Code via pluggable “blocks”

● Originally created by Google educational unit● Contributed to MIT Media Lab, open source● Apps not really suited for distribution

Page 42: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

App Generators

● Canned “Fill-in-the-Blanks” Apps– You provide details, it generates custom app on

a server for you to download and distribute● Focuses

– Specific verticals (e.g., restaurants) via vertical-specific templates

– General “oh, we should have an app” firms

Page 43: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

OK, So How Do I Choose?

Page 44: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

Who Is The User?

● Public Distribution?– UI/UX is fairly important for acceptance, good

reviews– Should look like other apps of its ilk

● Internal Distribution?– Long history of crap– Look-and-feel issues tend to be lower concern

Page 45: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

What Does the User Use?

● Supplied Device?– If so, and if Android, all options on the table

● BYOD?– Android Today (think multi-native

implementation)– Android Tomorrow (think cross-platform)– Android Forever (gain deep experience in one

area)

Page 46: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

What Do You Need?

● More Device-Centric, More Native– Contacts?– Camera?– Background data syncing?– Notifications?

● Simpler Requirements = More Flexibility in Development Choice

Page 47: Android Development: The 20,000-Foot View

  Copyright © 2013 CommonsWare, LLC

What Do You Know?

● All Else Equal, Pick a Gentle Learning Curve– Unless learning is the objective...– ...and all else may not be equal

● Benefits to Existing Experience– Level of effort = time/expense budget– Deadlines