Flash Development with Android SDK 1.5


Following on from my previous post below I have also been playing around with the Android SDK, and specifically with the Flash Player on the Hero.  It has been sometime since I did any programming, but some of you may know that I come from an engineering background.  So below I’m going to go over the different tools and technologies that I encountered during these two days.

Be warned, there’s code and geek talk below :-)

Step 1:  Get the SDK and tools


The Hero runs Android 1.5 with a custom UI from HTC called “Sense”.  With 1.5 comes a number of additional features like on-screen keyboards and Android Widgets.  All I needed to do was download the SDK for Eclipse, the same development environment we use for Flash Builder, or Carbide for Symbian C++.  The Android toolchain is a real dream and it runs across Mac, Windows and Linux with feature parity.

If you have Eclipse/FlashBuilder or Carbide installed then you’re good to go.  Just install the ADT plugin using software update, unzip the SDK into a relevant folder and point to it like this.

Picture 2

Instructions

Step 2: Create the HelloWorld app

It used to be that you had to actually type something to create your HelloWorld app, with Android there’s no need :-(  Using the File->New Project menu you create an Android Project, and setup the app name, package name and the name of your Activity; then click finish.

Picture 1

You’ll end up with a typical application created in the Package Explorer, and if you look in the source folder you find the generated .java files.  Remember that Android uses the Java language, but it’s own APIs, and so it’s familiar to look at.

Notice that my application extends Activity, part of the Android application package.  An Activity is generally considered an interactive component, like a screen or dialog.  For our purposes we can thinking of it like a MovieClip or UIComponent if your a Flex person.  In this auto-generated code we have simply overridden the onCreate method as this is the first function to be called.  There’s also an onStart method and that should be used if you want to be formal.

Picture 3Picture 4

From here I can simply run the emulator, but just for fun I decided to plugin my HTC Hero, go for bust I say!  The great news is that devices are auto-detected by the ADT plugin in Eclipse as shown above.  From here I can run or debug my application using the normal IDE buttons, and also with the SDK comes a nice tool to capture screenshots from the device while connected to the ADT plugin.

Picture 5

Step 3: Launch Flash Player Standalone

This is where things get more complex, simply because I don’t know exactly how the player was implemented for Android.  Android uses pretty standard methodology for application development, and so I can presume that the implementation followed the rules.  So what are the fundamental rules?

  • Activity – Is a UI component that presents itself to the user for interaction
  • Service – A background process that carries out a task for other components such as pulling emails and calendar synchronization.
  • Broadcast Receiver – A component that listens and does something in response to broadcasts.  Widgets are great examples of broadcast receivers.
  • Content ProviderA useful way of wrapping access to content, images, audio files or even data base access.

Activities, Services and Broadcast Receivers are all started by and registered to receive messages from the platform called Intents.  An Intent is a simple message object with a simple Action string and it’s also possible to send data, or call a specific component to handle the message.

So with a spot of “playing” around with a decompiler I was able to find two potential Intents.

1.  To launch the FilePicker with SWF/FLV files detected automatically.

Picture 6

This works pretty well, though seems restricted to landscape mode.

2.  To launch the player Activity (com.htc.flash.SingleViewActivity) directly passing a SWF file to play.

Picture 7

It’s possible to launch the Activity using this method but the file provided in “putExtra” doesn’t actually load.  So while this would be the best solution it appears like it’s designed not to work in this way.

So in summary, the only valid path for standalone apps (as far as I can tell) is to load the FilePicker.  This method is pretty good for on device testing, maybe you want to see what your mobile web site looks like and need to tailor the flash content to fit the screen.

Next we’ll look at the browser solution…

, ,

  • http://flashmobile.scottjanousek.com Scott Janousek

    Nice. My “shiny shiny” is on it’s way. :)

  • Pingback: Twitted by sjespers

  • http://www.biskero.org Alessandro

    Ciao Mark,

    looks like a similar method to create a launcher for Symbian by invoking the swf file.

    Alessandro

  • http://www.viewfromlondon.com Matt Millar

    So – what about using Android to launch an embedded webkit that contains HTML that just runs Flash full screen?

    Simple example WebView code here:

    http://code.google.com/p/apps-for-android/source/browse/#svn/trunk/Samples/WebViewDemo

    I don’t have a Hero to try this myself – but I’d love to know if it works (As I have an app that would use this!)

    • http://www.flashmobileblog.com Mark Doherty

      lol – that’s part 2.. and unfortunately not simple, they disabled plugins :-(

  • http://www.willna.com William

    Could you test something ?
    Via DDMS, it is said you can extract/add files from a phone filesystem…I wonder if you can extract the flplayer.apk from the HTC and put it on another phone, or at least on the virtual one…
    If they made the player not too linked to hardware, it should work since it’s android way to do….
    Helas, I assume they make it hardware related so I don’t think it will work but it’s definitly a test I would like to do ! :)

  • http://www.momac.net/www.boostermedia.com Laurens Rutten

    Hi Matt,

    I do have a HTC Hero and openened your link, what should the result be that makes you happy? The link on the Hero opens the same website as you would see in your regular webbrowser.

    I can send you a screenshot of the Hero after opening the link…?

  • Pingback: How to develope Flash applications with Android SDK 1.5 | Adobe Flash Lite

  • Pingback: HTC Hero has been aquired! « AdvancED: Flash on Devices

  • Pingback: Twitted by hpsaturn

  • Pingback: » HTC Hero / Android SDK / Flash Development Dale Rankine

  • Pingback: localToGlobal » news review -> 33th week of 2009

  • http://www.cubical.se Anders Kavcic

    Hey Mark, thanks for your posts about FL on Android!

    What about the Android widgets? Is it possible to build a widget that is Flash Lite based?

    • http://www.flashmobileblog.com Mark Doherty

      Hi Anders, The Widget SDK requires you to use Android XML declarative UI components, so it’s not possible I’m afraid.

  • http://www.cubical.se Anders Kavcic

    I see, thanks for your reply.

    Btw, I haven’t got an Android phone yet, what’s the performance like for FL apps on the HTC?

    I have been playing around with FL for Sony Ericsson W890i and Nokia 5310, dunno if you have any experience of these handsets. But I imagine that the HTC will run FL apps a lot smoother?

    • http://www.flashmobileblog.com Mark Doherty

      Hi Anders, the performance is really good overall. The other devices that you mention are lower end feature devices, and so performance isn’t as good. However FL has been tuned for those environments and so it’s not terrible by any means.

  • Pingback: Android Beyond Java, Part One | AndroidGuys

  • Pingback: Android Beyond Java, Part One | The Androider

  • Pingback: Android Beyond Java, Part One « Android Junkies

  • http://youtomp3.com/ convert youtube to mp3

    Thanks for posting the update with such detailed guidelines, seems like you have found a very good solution!