Sunday, November 25, 2012

RenderMode = direct required for camera in Adobe Air Android

I'll go over this one in reverse order to get the most relevant information in front of ya'll's eyeballs as fast as possible. (Oh yes I did just use a double contraction there.)

The Solution

When you want to get a raw, realtime image feed from the device camera in an Adobe AIR application on Android, you have to set the "renderMode" property in the app xml file to "direct" in order for it to work *at all*.

The Problem

If you don't set the renderMode property as such, when you are displaying the live camera image in your AIR app, you'll see something like this:
The gobbledeegook here has nothing to do with a turkey.

Just to be clear, I'm talking about the <renderMode>{someValue}</renderMode> node, which is a child of the <initialWindow> node in the AIR app xml file. To get things to work, "{someValue}" needs to be "direct."

As far as I can tell, I've come across this oh-so interesting behavior within a perfectly normal AIR application that I am running/developing/testing on my Android phone. These are the details on my app:
  • A Flex mobile app, running with installed AIR 3.5.
  • All UI layouts are in mxml.
  • In the code, the Camera/Video object instances are ending up added as a child to a <mx:UIComponent />.
  • My development device is a Galaxy S2 running Android 4.0.
Like I say, nothing too exotic going on there; seems like things should just work. I obviously had to go hunting when I first encountered this issue, but unfortunately I can't remember where I stumbled upon the idea to mess with the renderMode property. I'm aware it's possible this is specific to my device, version, etc. of Android.

But, Hopefully this will help someone out there!

No comments:

Post a Comment