15
Advanced Titanium Development for Android Don Thorp & Marshall Culpepper

Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

Embed Size (px)

DESCRIPTION

In this presentation, we will provide an overview of native Android tooling and some of its uses. We will also cover several Android specific concepts and APIs and discuss how you can use them when creating a best of breed application.Tooling- DDMS- adb (Android Debug Bridge)- android (Downloading SDKs, Managing AVDs)APIs- Android Lifecycle Events- Intents, Activities, Notifications- Javascript Activities- Resources- Android Section of tiapp.xml

Citation preview

Page 1: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

Advanced  Titanium  Development  for  Android  

Don  Thorp  &  Marshall  Culpepper    

Page 2: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

2 http://www.appcelerator.com | @appcelerator

Android Tooling

• Android Debug Bridge (adb) • DDMS (Dalvick Debug Monitor Server) • “android” • “hierarchyviewer” • “traceview”

Page 3: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

3 http://www.appcelerator.com | @appcelerator

Android Debug Bridge (adb)

•  the swiss army knife of Android, tons of commands, works with emulator & device • push / pull: upload / download files •  install / uninstall applications •  shell: full /bin/sh system access •  logcat: app / device logging

Page 4: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

4 http://www.appcelerator.com | @appcelerator

DDMS

• Graphical frontend to adb, and other android SDK tools • App process control • Colored Logcat output • Mock Geo / Phone call / etc control • Minimal memory / cpu profiling

Page 5: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

5 http://www.appcelerator.com | @appcelerator

Other Android SDK Tools

•  “android” – manage virtual devices (emulators w/ versions, SDcard

size, etc) – SDK updates, extras

•  “hierarchyviewer”: – Layout / UI debugging tool

•  “traceview” – Visual call hierarchy / CPU profiling

• Much more, See the official Android docs (links at the end)

Page 6: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

6 http://www.appcelerator.com | @appcelerator

Android Concepts •  Application – Collection of one or more Activities • Selected by OS w/ Intent filters

– SDK version compatibility (API Level)

•  Intent

– Fully serializable data, used between Activities – Various fields/options • Action (VIEW, EDIT, SEND, etc), Data (URI) • Category (CATEGORY_LAUNCHER etc) • Mime type (e.g. vnd.android.cursor.item/phone) • Class name (e.g. com.mycompany.Activity) • Extra’s - Custom key/value pairs

Page 7: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

7 http://www.appcelerator.com | @appcelerator

Android Concepts

• Activity –  Task Stack • Inter-app + screen navigation

–  App entry point –  Handle system+custom intents • Can return values to other activities

• Others –  Service –  Notifications, PendingIntent

Page 8: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

8 http://www.appcelerator.com | @appcelerator

App/Activity Life Cycle

• User launches app – Intent is fired to app

with: • category: CATEGORY_LAUNCHER • action: MAIN

Page 9: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

9 http://www.appcelerator.com | @appcelerator

How do I do that with Ti?

•  Custom JS Activities – JS Activities can be simple (launched via URL) or complex

(launched via intent filter from the system) – Configured via tiapp.xml

•  Everything else (mostly) follows a 1:1 mapping w/ official Android API – All constants / create* methods live in Ti.Android – i.e. Ti.Android.createIntent – Access current activity with Ti.Android.currentActivity – Activity.startActivityForResult supports a function

callback for convenience

Page 10: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

10 http://www.appcelerator.com | @appcelerator

Resources

• Use Android density / orientation res specifiers in Resources/android/images • Arbitrary android native resources can live

in project’s platform/android

Page 11: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

11 http://www.appcelerator.com | @appcelerator

tiapp.xml examples

Page 12: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

12 http://www.appcelerator.com | @appcelerator

JS Examples

Page 13: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

13 http://www.appcelerator.com | @appcelerator

Javascript Engines

• Rhino –  Our current Javascript Engine –  Java based which allows it to work on devices

without NDK support

• V8 –  Used in Chrome, Chromium, NodeJS, and more –  C++ based requires NDK support –  Performance 2X minimum, in many cases 10-15x

Page 14: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

14 http://www.appcelerator.com | @appcelerator

Titanium+Android Demos

Page 15: Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android

15 http://www.appcelerator.com | @appcelerator

Links!

• Android Tools: http://developer.android.com/guide/developing/tools/index.html •  Ti.Android module:

http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Android-module •  Services in Titanium:

http://developer.appcelerator.com/doc/mobile/android-simple-services