Developing for Android with the Flash Platform - Mihai Corlan [PDF]

0 downloads 129 Views 2MB Size Report
What Android phones? ▫ Flash Player 10.1 runs only on Android 2.2 or newer ... 10. Download Flash Player 10.1 and AIR runtime/SDK. ▫ hp://labs.adobe.com.
Developing for Android with the Flash Platform Replace with a graphic

White Master

5.5” Tall & 4.3” Wide

Mihai Corlan Platform Evangelist, Adobe gotoAndSki(), June 2010 Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

1

What Android phones?  

Flash Player 10.1 runs only on Android 2.2 or newer

 

Adobe AIR runs on Android 2.1 and 2.2

 

Phones: Motorala Droid, HTC Desire, Google Nexus One (ARMv7 processor)

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

2

API’s & Features  

 

Multi-Touch  

Works on Desktop for both Flash Player 10.1 and AIR

 

On Android works only in AIR

 

System.Capabilities.TouchScreenType (finger, none)

Mobile text input  

 

If no physical keyboard then the virtual one is bring on for text input fields

Accelerometer input  

Accelerometer class allows developer to read acceleration values on X,Y, and Z axes

 

Accelerometer.isSupported

 

flash.events.StatusEvent

 

flash.events.AccelerometerEvent (UPDATE)

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

3

API’s and Features  

Screen Orientation  

Stage object dispatches a StageOrientationEvent object when the orientation of the screen containing the stage changes

 

stage.orientation

 

StageOrientationEvent.ORIENTATION_CHANGING

 

StageOrientationEvent.ORIENTATION_CHANGE

 

Camera and Mic access don’t work on mobile

 

Geolocation  

Geolocation class

 

geoLocation.addEventListener(GeolocationEvent.UPDATE, handleLocationRequest);

 

GeolocationEvent properties: latitude, longitude, altitude, heading, speed, H&V accuracy, timestamp

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

4

API’s and Features  

Listening for Hardware buttons (Back, Menu, Search)  

Keyboard.MOBILE_BACK_KEY

 

Keyboard.MOBILE_MENU_KEY

 

Keyboard.MOBILE_SEARCH_KEY

 

Focused Mode (single tap)

 

Smartzoom (double tap)

 

Full-Screen AS-only  

stage.displayState = StageDisplayState.FULL_SCREEN;

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

5

API’s and Features Integration with the device Phone, Messaging, Email, Browser:  

navigateToURL(new URLRequest("tel:”

+ “00407668”));

 

navigateToURL(new URLRequest("sms:”

+ “00407668”);

 

navigateToURL(new URLRequest("mailto:"+ “[email protected]”))

 

navigateToURL(new URLRequest(“http://corlan.org”));

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

6

Optimizations  

Smart Rendering  

 

Sleep Mode  

 

Flash content that’s not visible to the user will not be rendered and will receive limited CPU time

The player will be put to sleep along with the device to conserve power

Out-of-Memory Management  

“click-to-play” button that the user can control as necessary

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

7

What languages/frameworks  

For browser you should stick to ActionScript projects. While Flex 4 works in browser, you might not get the performance you are looking for

 

For AIR I found Flex 4 framework could be a good choice. Test for your specific use case because your mileage could vary

 

A number of people created light-weight components for mobile development:  

http://dgrigg.com/post.cfm/04/28/2010/Alpha-Release-of-Skinnable-Minimal-Components

 

http://blog.kevinhoyt.org/?p=548

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

8

Android SDK  

You have to download the Android SDK

 

This offers the command line tools necessary for installing/uninstalling APK files, displaying the Console, screen capturing and so on

http://developer.android.com/sdk/

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

9

Download Flash Player 10.1 and AIR runtime/SDK  

http://labs.adobe.com  

AIR 2.5 Runtime Device (Éclair / FroYo) (APK files)

 

AIR 2.5 SDK Windows / Mac / Linux

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

10

Installing APK files to your Android  

Connect your phone to your computer using the USB cable

 

Navigate to Android SDK/tools/ folder and run adb command:

adb devices This command should list your device

 

Run this command to install APK files:

adb install Runtime_Device_Froyo_20100517.apk

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

11

Tools for developing AIR apps for Android  

Flash CS 5. You can install a plug-in for Android

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

12

Tools for developing AIR apps for Android Flash Builder 4

 

Download AIR SDK 2.5 for your OS

 

Create an AIR app

 

If you use Flex, change the root node from WindowedApplication to Application

 

Application descriptor file:  



 

mobileDevice

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

13

Deploying from Flash Builder 4  

You can use Serge Jespers’s Package Assistant Pro http://www.webkitchen.be/package-assistant-pro/

 

Can package your project as an APK file

 

Then you can use “adb install appname.apk” command

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

14

Deploying from Flash Builder 4 Or you can create a script (sh / bat) that grabs the files from bin-debug, package them as an APK file, uninstall the app from the phone, install the new app rm -f install.apk

/Users/mcorlan/Desktop/Android/android-sdk-mac_86/tools/adb uninstall app.aTabSplitterSkunkwork

java -jar /Users/mcorlan/Desktop/Android/adt.jar -package -target apk -storetype pkcs12 -keystore /Users/mcorlan/Desktop/ Android/mcorlan2.pfx -storepass 12cor13 install.apk main-app.xml main.swf

/Users/mcorlan/Desktop/Android/android-sdk-mac_86/tools/adb install -r install.apk

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

15

Seeing the Android console  

Connect your Android Phone

 

Enable debugging on device

 

Open a terminal window and execute this command: adb logcat

 

You’ll see all the traces and exceptions in the console

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

16

Device Central CS5  

You can use Device Central CS 5 for testing your Flash Application

 

Doesn’t support AIR

 

You publish from Flash CS5 your application

 

In Device Central you add a Nexus One profile and load the SWF

 

Then you can use the emulator for testing the app on the phone, including the accelerometer, keyboard

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

17

Resources  

Gotoandlearn.com – tutorial on installing the Android SDK, AIR runtime, and AIR extension for Flash CS5

 

http://www.webkitchen.be/package-assistant-pro/

 

http://flashmobileblog.com

 

http://corlan.org

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

18

Q&A

Replace with a graphic

White Master

5.5” Tall & 4.3” Wide

Thank You! http://corlan.org Twitter: mcorlan

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

19

Packaging & Pricing – Available for purchase March 22, 2010

Flash Builder 4 Standard

Flash Builder 4 Premium

ColdFusion Builder

$249 / $99

$699 / $299

$299

€175 / €69 Y30000 / Y12000

€519 / €229 Y85000 / Y36000

€215 Y34000

Standalone or included in ColdFusion Builder

Adds profilers, network monitor, unit testing harness and integration, command-line build

Free for Education

Includes ColdFusion Builder

Standalone or included in Flash Builder 4 Premium

Free for Education Includes Flash Builder 4 Standard ®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

20

®

Copyright 2010 Adobe Systems Incorporated. All rights reserved. Adobe confidential.

21