[Resolved] Download image to DocumentsDirectory then show on a scene.

Hello

Need a little help please. I found in the forum messages a prefered method to downloading an image from a web site to the DocumentsDirectory of an Android device and how the procedure can then show the image on a scene. The sample code uses the link: http://developer.anscamobile.com/demo/hello.png for the test image.

I “copied” the sample text to my lua file and the simulator shows the image is in fact in the DocumentDirectory (image does get downloaded). However, I can’t seem to get it show on the scene. I thought maybe it was the simulator, so I compiled the APP and tried placing the APP file on my phone and not even in the DocumentDirectory shows the file gets downloaded (much less the scene showing it). Here is what the code looks like:

local function networkListener( event )
if ( event.isError ) then
print ( “Network error - download failed” )
else
img3 = display.newImage( “helloCopy”, system.DocumentsDirectory, 60, 40 )
img3.alpha = 0
transition.to( img3, { alpha = 1.0 } )
end

print ( "RESPONSE: " … event.response )
end
network.download(
http://developer.anscamobile.com/demo/hello.png”,
“GET”,
networkListener,
“test.png”,
system.DocumentsDirectory )
local baseDir = system.DocumentsDirectory
local img3 = display.newImage(“test.png”, baseDir)
img3.x=screen_maxx-(img1.width/2)+12
img3.y=screen_miny+(img1.height/2)+12

Any help would be very much appreciated!

  • TIA [import]uid: 150241 topic_id: 28061 reply_id: 328061[/import]

Rough example -
[lua]local function networkListener( event )
if ( event.isError ) then
print ( “Network error - download failed” )
else
end
print ( "RESPONSE: " … event.response )
end

network.download(
http://developer.anscamobile.com/demo/hello.png”,
“GET”,
networkListener,
“test.png”,
system.DocumentsDirectory )

timer.performWithDelay(1000, function()
local test = display.newImage( “test.png”, system.DocumentsDirectory )
end, 1)[/lua] [import]uid: 52491 topic_id: 28061 reply_id: 113473[/import]

Hi

Sorry for the delay in response…been trying to figure out two issues. One issue related to the above code is:

My best guess (I’m a newbie at using Corona), is that system.DocumentsDirectory doesn’t exist on a Zoom, right? The code (above) works on my droid phone, but it fails on my Zoom. Is there a universal place I can use to “store” the image?

I’ll open up a new post for the second issue…

Thanks

Jim [import]uid: 150241 topic_id: 28061 reply_id: 113947[/import]

Good evening Jim,

I don’t work with Android but it seems odd to me that it wouldn’t have a system.DocumentsDirectory - I’m going to ask Josh (our Android guru) about that and see if he can shed some light on this for us.

Hang tight! [import]uid: 52491 topic_id: 28061 reply_id: 114033[/import]

Hi again Jim,

I have spoken with Josh (to confirm we think you’re talking about the Motorola Xoom, yes?) and he’s confirmed we do have one of these in the office and the DocumentsDirectory is definitely accessible - so one thought was that you may be out of storage space.

You can check this by;

  1. Tap the Home button.
  2. Tap the Menu button.
  3. Select “Settings” from the popup menu.
  4. Select “Storage” from the list.
  5. Check if their is enough “Available Space”.

Note that the Documents, Temporary, and Caches directory always reside in “internal storage” and never on “external storage”. Regardless if the app was installed on external storage. The Android OS does it this way on purpose to secure/protect the app’s data.

I hope this proves useful :slight_smile:

Peach [import]uid: 52491 topic_id: 28061 reply_id: 114178[/import]

Hi

Ok…I think I’ve wore out my keyboard trying to resolve this issue. :frowning:

You are correct it is a Motorola Xoom and it has plenty of memory. :slight_smile:

But…I think I need to get a professional to help on this APP. There are 3-4 other things (besides this one) that needs fixing. Your certified developers link isn’t open yet - any recommendations?

Jim [import]uid: 150241 topic_id: 28061 reply_id: 115029[/import]

The Studio Directory lists a number of devs worth contacting, although if you post in MarketPlace sub forum you will likely get some bites there :slight_smile: [import]uid: 52491 topic_id: 28061 reply_id: 115117[/import]

Hi

I’m not sure exactly where to “brag” about a developer that recently helped me - so I’m sorry if this isn’t the place. If I’m wrong, please redirect me to that place.

I recently needed a few things done to my APP that I couldn’t figure out. I received an email from Jamie Trinder and I was quite impressed. Within a few hours (and only slightly over buget) Jamie with T and G Apps Limited did a fantastic god.

I’d recommend anyone to reach out to them should they need assistance.

Jim [import]uid: 150241 topic_id: 28061 reply_id: 118091[/import]

Hey Jim - good on you for posting about that, it’s great to give credit where it’s due :slight_smile: Jamie is very cool!

Peach :slight_smile: [import]uid: 52491 topic_id: 28061 reply_id: 118153[/import]