I have a print statement just before and just after this line, and it’s not printing the one after, so I know it’s not going past here.
To test the PNG is ok, I put it in the main app folder and built it into the app, and displayed it when the app starts, which succeeds. It’s also fine on the simulator. Any thoughts welcome.
[import]uid: 23949 topic_id: 6289 reply_id: 306289[/import]
Are you sure the file is downloading? How do you know? If there is a download, what is the size of the file? Can you open it?
[import]uid: 8045 topic_id: 6289 reply_id: 21674[/import]
In reply to your previous post, I’ve grabbed it from the /data/ folder on my phone using adb and viewed it. It also displays *on my phone* if it’s loaded from the resource folder. I just can’t get it to display from the documents directory. [import]uid: 23949 topic_id: 6289 reply_id: 21676[/import]
This is really driving me crazy. I’ve just done another test, which is to copy the file as downloaded into the simulator’s sandbox documents folder and try the following code to simply load the image in the simulator:
I’ve verified that file and path exist (guess you’ll have to take my word for it). How could this fail? It’s really busting my &*^*& [import]uid: 23949 topic_id: 6289 reply_id: 21675[/import]
Here, try this. Create a main.lua file, copy and paste this into the file and try running it in the simulator. It should display the Google logo to the bottom and right.
[lua]local http = require(“socket.http”)
local ltn12 = require(“ltn12”)
–this will download an image from the web
function downloadImage(filename,suburlpath,tld,x,y)
local fileNameString = filename
local imagePathString = suburlpath
local imagePath = system.pathForFile( fileNameString, system.DocumentsDirectory )
local myfile = io.open(imagePath, “w+b”)
http.request{ url = tld … imagePathString, sink = ltn12.sink.file(myfile) }
local image = display.newImage(fileNameString,system.DocumentsDirectory, x, y);
end
–call the function
downloadImage(“blah”,
“/images/logos/ps_logo2.png”,
“http://www.google.com”,
display.contentCenterX - 10,
display.contentCenterY
)[/lua] [import]uid: 8045 topic_id: 6289 reply_id: 21677[/import]
I got quite a long delay before the “Corona trial” pop-up appeared, then nothing, just a blank screen. It worked in the simulator however. Appreciate your time. Why wouldn’t this be working? I’m running a Dell Streak with Android 2.2.
Edit: I think it was killed for taking too long to start??
[lua]W/ActivityManager( 149): Launch timeout has expired, giving up wake lock!
W/ActivityManager( 149): Activity idle timeout for HistoryRecord{470ed140 com.blah.blah.apps/.MyCoronaActivity}
I/ActivityManager( 149): Displayed activity com.blah.blah.apps/.MyCoronaActivity: 25235 ms (total 25235 ms)[/lua]
[import]uid: 23949 topic_id: 6289 reply_id: 21679[/import]
Thanks again. I’m going to sleep on it. I’m sure it will be something simple, but there are quite a few gotchas to Corona development on Windows as I’ve found. Or maybe it’s just me [import]uid: 23949 topic_id: 6289 reply_id: 21683[/import]
I’ve tried the above code, it builds and works fine in the Corona emulator but when i install it in my HTC Desire HD - Android 2.2 it just halts when it is going to show the image. The program gets unresponsive.
If I exit the program and go in to the program manager i can see that the data for my program is now 8kb instead of 0kb, exactly as big as the image I’m trying to load is.
What might be the problem?
EDIT: I downloaded an build the example: http://developer.anscamobile.com/content/simple-image-download and it din not work either… Same thing here, the app data grow from 0 to 4kb (witch is the image) when i pres download but no image shows up. At least this one does not hang up.
[import]uid: 28895 topic_id: 6289 reply_id: 21687[/import]
Have you tried saving the image to “/” instead of sub-folders?
Just a thought. I just had some issues with my apps not loading due to images in sub-folders… [import]uid: 20046 topic_id: 6289 reply_id: 22153[/import]
Did you set permission to access the internet? Without it your android device won’t be able to download stuff from the net. [import]uid: 5712 topic_id: 6289 reply_id: 22158[/import]
Well, hope it gets fixed soon.
I actually encountered this problem on ipod and iphone, for both the resource and document directory. If I just do something like display.newImage(“folder/image.png”… it works ok. If I use the pathForFile it doesn’t. The real problem is the documents directory, where the pathForFile is needed, and I actually really need this to work.
Anyone know a work around for the documents directory? :\ [import]uid: 8486 topic_id: 6289 reply_id: 22484[/import]