Launching the camera from an AIR for Android app

To access the smartphone camera from an AIR for Android app, you can try the following code. It would launch the camera and let use capture a photo. It then trace the photo name/path which you can use a loader object to load it onto the AIR app.

import flash.media.CameraUI;

import flash.events.MediaEvent;

import flash.media.MediaPromise;

import flash.media.MediaType;

var cam:CameraUI = new CameraUI();

cam.addEventListener(MediaEvent.COMPLETE, doComplete);

function doComplete(e:MediaEvent):void

{var mp:MediaPromise = e.data;  trace(mp.file.url);}

cam.launch(MediaType.IMAGE);

Advertisements

~ by brianchau on August 22, 2012.

6 Responses to “Launching the camera from an AIR for Android app”

  1. how do u launch CameraRoll only for videos?
    saw some (native I guess) apps that do that.

    • Try this isntead:

      cam.launch(MediaType.IMAGE);

      • nope. cameraRoll does not have that launch method.
        I guess I need a native extension.

        PS: the native facebook app does that when you try to add a picture. lets you select either photos or videos, and if you select videos you can only see the videos from your gallery.

  2. I have been browsing online more than 3 hours today, yet I never found any
    interesting article like yours. It’s pretty worth enough for me. In my view, if all web owners and bloggers made good content as you did, the web will be much more useful than ever before.|
    I couldn’t resist commenting. Perfectly written!
    |
    planning to get one as soon as i get paid

  3. I personally consider this amazing article ,
    “Launching the camera from an AIR for Android app | Brian Chau”, pretty engaging
    plus the post was in fact a remarkable read. Many thanks,Davis

  4. I’m really enjoying the design and layout of your blog. It’s a very easy on the eyes which
    makes it much more pleasant for me to come here and visit
    more often. Did you hire out a designer to create your theme?
    Outstanding work!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: