How to display photo from media.PhotoLibrary

Hello everyone! So, in this app I’m working on, I want the user to have the ability to make the app background an image from their photo library. I’ve checked out the media API’s, so I’m sorta familiar with them, however, I can’t get it to work.
I just want it in the most basic form: user presses button, they select image from library, then the image shows up in app screen. I want the image to be “remembered” so it’s still there next time the app is opened. I don’t need help with the button… :stuck_out_tongue:

So, if you have an example, doc, tutorial, or something else useful, I’d appreciate it if you shared! :slight_smile:

Thanks
Nathan [import]uid: 39302 topic_id: 30971 reply_id: 330971[/import]

You should copy the image from Gallery to Documents directory. This is the only way. [import]uid: 138389 topic_id: 30971 reply_id: 123871[/import]

you can do it like this

[lua]local function onComplete(event)
–no need to do anything here image is saved by themedia.show() function itself
end

–you can call this in button press
local filePath = { baseDir = system.DocumentDirectory, filename = “BKGImage.jpg” }
media.show( media.PhotoLibrary, onComplete, filePath )[/lua]

this saves image in document directory. [import]uid: 71210 topic_id: 30971 reply_id: 123905[/import]

Will that work on the corona simulator, or will I need to test it on a device?
Could I then display that image by using display.newImage()? [import]uid: 39302 topic_id: 30971 reply_id: 123964[/import]

You should copy the image from Gallery to Documents directory. This is the only way. [import]uid: 138389 topic_id: 30971 reply_id: 123871[/import]

you can do it like this

[lua]local function onComplete(event)
–no need to do anything here image is saved by themedia.show() function itself
end

–you can call this in button press
local filePath = { baseDir = system.DocumentDirectory, filename = “BKGImage.jpg” }
media.show( media.PhotoLibrary, onComplete, filePath )[/lua]

this saves image in document directory. [import]uid: 71210 topic_id: 30971 reply_id: 123905[/import]

Will that work on the corona simulator, or will I need to test it on a device?
Could I then display that image by using display.newImage()? [import]uid: 39302 topic_id: 30971 reply_id: 123964[/import]