I’m on Mac OSX but this also reproduces on device. The special trick here seems to be using a coroutine. Without it, it still functions as you might expect.
Reproducing code:
[lua]
local native = require “native”
print("Running in simulator version " … system.getInfo(‘build’))
local function callback()
print(“You don’t see this print.”)
end
local function onNetworkChangedEvent()
print(“Showing alert”)
native.showAlert(“Hello”,
“I am an alert. Something changed”,
{“Great!”},
callback)
end
print(“Creating coroutine”)
co = coroutine.create(function()
print(“Yielding…”)
coroutine.yield()
if network.canDetectNetworkStatusChanges then
print(“Setting status listener”)
network.setStatusListener(“www.apple.com”, onNetworkChangedEvent)
end
end)
coroutine.resume(co)
coroutine.resume(co)
[/lua]
Output:
2013-09-18 12:12:39.809 Corona Simulator[71797:f03] Running in simulator version 2013.1137 2013-09-18 12:12:39.809 Corona Simulator[71797:f03] Creating coroutine 2013-09-18 12:12:39.810 Corona Simulator[71797:f03] Yielding... 2013-09-18 12:12:39.810 Corona Simulator[71797:f03] Setting status listener 2013-09-18 12:12:39.859 Corona Simulator[71797:f03] Showing alert 2013-09-18 12:12:40.613 Corona Simulator[71797:f03] Runtime error attempt to call a nil value stack traceback: [C]: ? 2013-09-18 12:12:40.619 Corona Simulator[71797:f03] RuntimeErrorNotification: Failed to parse error message: attempt to call a nil value