I got stuck on this issue when I was trying to implement the camera in Corona.
Below is my code:
local savedImage = “myImage.jpg”
local function handleButtonEvent (event)
if ( media.hasSource( media.Camera ) ) then
media.capturePhoto( {
listener = onPhotoComplete,
destination = {
baseDir = system.DocumentsDirectory,
filename = savedImage,
type = “image”
}
})
else
native.showAlert( “Corona”, “This device does not have a camera.”, { “OK” } )
end
return true
end
local function onPhotoComplete( event )
if (event.target) then
media.save(savedImage , system.DocumentsDirectory)
end
end
I tested above code on Android device and the images taking feature was working fine, other than the issue that all images taken by the camera will be saved as some sort of default name like picture1, picture2, picture3 … I was expecting they have desired name, however, which is savedImage in my example. Can anyone explain this to me?
Much appreciated!!!