Check Internet connection

Hey guys,

is there some method that corona can check if there is an internet connection?

The scenario is like this, a user will click a button that will download a json file then extract and reads and so on. But if there is no connection what happens then? which the button is always available in the menu to be pushed.

Any suggestion on how to do this? [import]uid: 141531 topic_id: 27057 reply_id: 327057[/import]

Hey there,

See this; http://developer.anscamobile.com/code/check-internet-connection

Peach :slight_smile: [import]uid: 52491 topic_id: 27057 reply_id: 109871[/import]

Oh, Thanks Peach. :slight_smile:

Upon looking at the code I noticed that this what I am using already. My main problem is that whenever I download the json file with my simulator it can download it but if i build to my tab(android) it freezes.

What it does first is download the json file the decodes it then deletes the devices database and loads the new one with the information from the json file. It seems to reach the deleting part but it just freezes. What is wrong?

[lua]local response = http.request(“http://…”)
if response == nil then
print (“NO DATA FOUND”)
else
local path = system.pathForFile( jsondata, system.DocumentsDirectory )
local myFile = io.open( path, “w+b” )

– Request remote file and save data to local file
http.request{
url = “http://…”,
sink = ltn12.sink.file(myFile)
}
cleanDB() fillUpDB() reloadFreeplay() native.setActivityIndicator(false)
end[/lua]

I hope you understand what i’m trying to say and I hope you have something to say to fix this problem. [import]uid: 141531 topic_id: 27057 reply_id: 110069[/import]