Skip to main content
Inspiring
August 3, 2017
Question

Android + CameraUI

  • August 3, 2017
  • 5 replies
  • 1588 views

Hello,

I am testing on Galaxy S7, Android 7.0 and AIR SDK 25

Tried following CameraUI examples and asking for permissions, yet the images taken are never loaded:

Media captured...

Asynchronous media promise.

Error #2044: Unhandled IOErrorEvent:. text=Error #2124: Loaded file is an unknown type.

Tracing the mediapromise URL returns:

file:///data/user/0/******/cache/Pictures/IMG_20170803_1517591533635246.jpg

(*** above are my package name)

Any ideas?

This topic has been closed for replies.

5 replies

Inspiring
December 26, 2017

So no one is using CameraUI on Android?

Bug posted on:

Tracker

Participant
November 11, 2017

When Take Photo and temp image file is made by device

First Path is temp Dictionary

and After Path is Gallery Dictionary

When I Load Photo path is Changed

so Cannot load photo because I got path temp Dictionary path

Inspiring
August 17, 2017

just as an update. the app runs fine on ios. the issue seems with android. So to summarize:

CameraUI does not work on android air sdk 24 25 or 26.

Makes you doubt the QA of the air sdk and that whole roadmap thing . . . There is something broken in how you manage your releases. You fix something and break another major thing.

We are switching to another platform as we cannot just wait for you guys to fix what should be working out of the box. Either open source it if you cannot fix it or just quit.

Inspiring
August 4, 2017

Yes Iam asking for it via requestPermission. The camera opens and I take a picture. But when I press OK the Image is never loaded.

Inspiring
August 4, 2017

Show your code then starting with the event handling the promise > (MediaEvent.COMPLETE)

Inspiring
August 7, 2017

ASWC  wrote

Show your code then starting with the event handling the promise > (MediaEvent.COMPLETE)

I also checked on Samsung J5, Android 6.0.1, same issue, here is the code:

private var deviceCameraApp:CameraUI = new CameraUI();

private var imageLoader:Loader;

private function barClicked(e:MouseEvent):void

{

//dispatchEvent(new MouseEvent(MouseEvent.CLICK));

if( !CameraUI.isSupported ) return;

if(CameraUI.permissionStatus != PermissionStatus.GRANTED)

{

deviceCameraApp.addEventListener(PermissionEvent.PERMISSION_STATUS, permissionChange, false, 0, true);

try {

deviceCameraApp.requestPermission();

} catch(e:Error)

{

// another request is in progress

}

return;

}

connectCamera();

}

private function permissionChange(ev:PermissionEvent):void

{

if (ev.status == PermissionStatus.GRANTED)

connectCamera();

}

private function connectCamera():void

{

deviceCameraApp.addEventListener( MediaEvent.COMPLETE, imageCaptured );

deviceCameraApp.addEventListener( Event.CANCEL, captureCanceled );

deviceCameraApp.addEventListener( ErrorEvent.ERROR, cameraError );

deviceCameraApp.launch( MediaType.IMAGE );

}

private function imageCaptured( event:MediaEvent ):void

{

trace( "Media captured..." );

var imagePromise:MediaPromise = event.data;

if( imagePromise.isAsync )

{

trace( "Asynchronous media promise." );

imageLoader = new Loader();

imageLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, asyncImageLoaded );

imageLoader.contentLoaderInfo.addEventListener( IOErrorEvent.IO_ERROR, cameraError );

imageLoader.loadFilePromise( imagePromise);

}

else

{

trace( "Synchronous media promise." );

imageLoader.loadFilePromise( imagePromise );

showMedia( imageLoader );

}

}

private function captureCanceled( event:Event ):void

{

trace( "Media capture canceled." );

}

private function asyncImageLoaded( event:Event ):void

{

trace( "Media loaded in memory." );

showMedia( imageLoader );   

}

private function showMedia( loader:Loader ):void

{

this.addChild( loader );

}

private function cameraError( error:ErrorEvent ):void

{

trace( "Error:" + error.text );

}

Inspiring
August 4, 2017

Just tried AIR 24 - 25 - 26, same issue, cannot load any image from CameraUI.

Made sure to add

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

I tried imagePromise.open(); and waiting for the data to load, but bytes loaded have 0 in length

Inspiring
August 4, 2017

You have the camera permission as well?