Assuming that you have similar code snippet for capturing image on Android using Camera UI as given below, here is a way to beat a very irritating bug in Adobe AIR for android. Just follow the steps mentioned and perhaps you can rid yourself of this issue completely.
if( CameraUI.isSupported )
cameraUI = new CameraUI();
cameraUI.addEventListener( MediaEvent.COMPLETE, imageSelected );
cameraUI.addEventListener( ErrorEvent.ERROR, mediaError );
cameraUI.launch( MediaType.IMAGE );
trace( "CameraUI is not supported.");
private function mediaError(E:ErrorEvent):void
trace("AN ERROR OCCURED");
private function imageSelected( event:MediaEvent ):void
cameraUI.removeEventListener( MediaEvent.COMPLETE, imageSelected );
cameraUI.removeEventListener( ErrorEvent.ERROR, mediaError );
cameraUI = null;
Why do you get double images ?
It seems that the CameraUI and Adobe AIR both save one copy each of the image. On your Android device, The CameraUI usually saves to CameraRoll standard folder, where as Adobe AIR saves it to a different folder:
CameraUI saves to – /mnt/sdcard/DCIM/100MEDIA
Adobe AIR saves to – /mnt/sdcard/DCIM/Camera
So when you go to CameraRoll you see 2 images because android will scan for all newly taken images.
What can you do ?
What i suggest is that after you have got the event.data.file object using MediaEvent, determine the last modified time of this file.
Next look for any file whose Last Modified DateTime is exactly the same as event.data.file. (You can do this by listing the CameraUI directory and filtering the files by Last Modified DateTime to get the one you are looking for)
Yes it may sound tedious but its important because the filenames used for both images are different. So you need to either use Last Modified DateTime or Some sort of file checksum technique.
Once you have located the duplicate file inside CameraUI directory delete it instantly.
If this bug is really critical to your project, you can try this method. If not then live with it 🙂 and tell your customer we will fix it when adobe does. 🙂
Note: I havent had time to personally cook up a demo apk file, but i am guessing this will work.