I want my app do be launched from the android image gallery or whereever a user selects an image and opens the share with dialog.
I already managed that my app will show up in the share with dialog and my app will also launch on that request but how will I get the image that the user wants to share with my app ??
i tried to read the launchArgs but without any success.
Some ideas on that?
thx
here is a code snippet of my main.lua
local function handleLaunch(event)
if (event and event.url) then
local url = event.url
if (string.sub(url, 1, 7) == “file://”) then – handle file
local alert = native.showAlert( “Got file url”, url, { “OK” })
else
local alert = native.showAlert( “Got url”, url, { “OK” })
end
already looks good, but how do I open the image??
I tried photo lib plus to get the image with this photo id (48670) but without success…seems to be a different id.
(btw…photo lib plus is working fine with id’s coming from photoLibPlus.listImages())
I assume you want to display the image using display.newImage() or display.newImageRect()?
If so, you have to use the file IO functions to open the path to the file: /media/external/images/media/48670 in binary mode, read the data in, write it out to system.TemporaryDirectory (or other appropriate sandbox folder) and then you can use display.newImage() to read the file and make a display object out of it.
yes…you are right, I want to open the image, but the path seems not to be a path to a file or image. As you can see there is no file extension, also this directory structure does not exist on the device. ???
After doing a search on the content URL provided, it seems that it’s a stream of data, not a file. Corona SDK isn’t going to have a way to process this data.
Looking at that post, it’s possible to use Enterprise to convert the URL provided and convert it to a filename. Since you’re an Enterprise customer, I’d consider going this route.
already looks good, but how do I open the image??
I tried photo lib plus to get the image with this photo id (48670) but without success…seems to be a different id.
(btw…photo lib plus is working fine with id’s coming from photoLibPlus.listImages())
I assume you want to display the image using display.newImage() or display.newImageRect()?
If so, you have to use the file IO functions to open the path to the file: /media/external/images/media/48670 in binary mode, read the data in, write it out to system.TemporaryDirectory (or other appropriate sandbox folder) and then you can use display.newImage() to read the file and make a display object out of it.
yes…you are right, I want to open the image, but the path seems not to be a path to a file or image. As you can see there is no file extension, also this directory structure does not exist on the device. ???
After doing a search on the content URL provided, it seems that it’s a stream of data, not a file. Corona SDK isn’t going to have a way to process this data.
Looking at that post, it’s possible to use Enterprise to convert the URL provided and convert it to a filename. Since you’re an Enterprise customer, I’d consider going this route.
I’m preparing some samples to show its functionality. For example, with this plugin it is so easy to get a file (custom extension) that it is open with our app.
I’m preparing some samples to show its functionality. For example, with this plugin it is so easy to get a file (custom extension) that it is open with our app.