How to make sure a person is connected?

Hi I’m having some problem. As you see I want to do is have person know when they are going to play is if they have connection. I want to display like a message on there screen telling them if they have connection or not. Can anyone please help me and show me how to do it. Help would be appreciated :slight_smile: [import]uid: 17058 topic_id: 22232 reply_id: 322232[/import]

You can borrow the code from my webpopups demo:

http://bluebilby.com/2011/12/19/sample-code-for-corona-webpopups/

[lua]-- Function to call to test if we have –
– a Network connection thru 3G or WiFi –
local function testNetworkConnection()
local google = require(‘socket’).connect(‘google.com’, 80)
if google == nil then
return false
end
google:close()
return true
end[/lua]

[lua]-- If network exists, do something –
if testNetworkConnection() == true then
– do something

– If no network connection detected, create an alert –
– and advise the user to turn on a network connection –
else native.showAlert( “Warning!”, “No network detected. Please connect to 3G or Wifi.”, { “OK”, }, toMenu )
end[/lua]

‘toMenu’ is a function to call when OK is pressed. [import]uid: 10389 topic_id: 22232 reply_id: 88552[/import]

@Waulok hey thanks alot exactly what I was looking for it works :slight_smile: [import]uid: 17058 topic_id: 22232 reply_id: 88555[/import]

Glad to help out :slight_smile:

Tell all your friends!!! [import]uid: 10389 topic_id: 22232 reply_id: 88560[/import]

@Waulok just one last questions how do I change scene when they click on the alert system. [import]uid: 17058 topic_id: 22232 reply_id: 88561[/import]

Check out the link to my page. It has a Director change scene built into that function… [import]uid: 10389 topic_id: 22232 reply_id: 88562[/import]

@Waulok I did it like this

[code] local function toMenu(e)
if e.action == “clicked” then
if e.index == 1 then

director:changeScene (“menu”, “flip”)
timer.cancel (timer1)
end
end
end

local function toMenu (e)
if testNetworkConnection() == true then
– do something

– If no network connection detected, create an alert –
– and advise the user to turn on a network connection –
else native.showAlert( “Warning!”, “No network detected. To buy more Minecraft Questions Please connect to 3G or Wifi.”, { “OK”, }, toMenu )
end
end
Runtime:addEventListener(“enterFrame”, toMenu)[/code]

I seem to have a problem removing the alert and changing scenes [import]uid: 17058 topic_id: 22232 reply_id: 88563[/import]

I don’t have a check for e.action in mine.
You also should not need a runtime on yours.
That’s for if there IS a network and it displays the popup, then I have a button for going back to the menu. [import]uid: 10389 topic_id: 22232 reply_id: 88564[/import]

@Waulok is ok now your website helped I got under control again thanks alot :slight_smile: [import]uid: 17058 topic_id: 22232 reply_id: 88565[/import]