display.save does not work on andoird

Hey guys when I use display.svave on android to save an image and upload it my server, i constantly get a black  or clear image with no data in it.

Here is my code:

[lua]

– Completion listener

local function onComplete(event)

  local photo = event.target

local saveGroup = display.newGroup()

saveGroup:insert( photo )

– Save the photo into the temporary directory 

display.save( saveGroup,‘1.png’, system.TemporaryDirectory )

photo:removeSelf()

local r = display.newImageRect(‘1.png’, system.TemporaryDirectory,100,100)

r.x = display.contentWidth/2

r.y = display.contentHeight/2

end

– Button tap listener

local function pickPhoto( event )

    – Note: Only use one of the media.show routines listed below

    – Save photo to file in Temporary directory

    --media.capturePhoto( {listener = onComplete, destination = {baseDir=system.TemporaryDirectory, filename=“image.jpg”, type=“image”} } )

    – Show photo on screen (no file save)  

    media.capturePhoto( {listener = onComplete } )

end

local button = display.newRect(120,240,80,70)

button:addEventListener(“tap”, pickPhoto )

[/lua]

Any one encounter this before?

Thanks.

Hi @Appoet,

Just to confirm, do you have the proper permissions for camera and writing external storage declared in your build.settings file? After completing the “pickPhoto()” process, if you temporarily comment out the “removeSelf()” line, do you see the photo on screen? On that note, why are you showing the photo, then removing it, then re-loading (re-displaying it) from the saved file using a separate call?

Best regards,

Brent

I figured out the issue and got it work. I had to call display.save before I remove the object. In fact display.save only saved the part of the object that was on the screen. I’m sure thats how it’s supposed to work and I didn’t didn’t put it together at time. 

Thanks.

Hi @Appoet,

Just to confirm, do you have the proper permissions for camera and writing external storage declared in your build.settings file? After completing the “pickPhoto()” process, if you temporarily comment out the “removeSelf()” line, do you see the photo on screen? On that note, why are you showing the photo, then removing it, then re-loading (re-displaying it) from the saved file using a separate call?

Best regards,

Brent

I figured out the issue and got it work. I had to call display.save before I remove the object. In fact display.save only saved the part of the object that was on the screen. I’m sure thats how it’s supposed to work and I didn’t didn’t put it together at time. 

Thanks.