leif3
January 1, 2016, 3:05pm
1
My app compiles and runs perfectly for Android (on a Windows machine). But when running it on a mac, it crashes when receiving data from the network.
I send a request over http,
requestID = network.request(data, "GET", networkListener)
My networkListener looks like this,
local function networkListener( event ) if ( event.isError ) then native.showAlert("GEOREG", "Nettverksfeil, er dataforbindelse aktivert?", {"OK"}) else native.showAlert("GEOREG", event.response, {"OK"}) end network.cancel(requestID) end
It seems like something in networkListener causes the crash. Can anybody help me out on this?
leif3
January 1, 2016, 10:41pm
2
This is the “crook”,
network.cancel(requestID)
Dunno if it’s necessary or not, but removing it cured the crash.
rob
January 1, 2016, 11:25pm
3
Yea, you shouldn’t cancel an event from its call back listener. You should wrap the call in a timer call:
timer.performWithDelay(10, function() network.cancel( requestID ); end)
Rob
leif3
January 1, 2016, 10:41pm
4
This is the “crook”,
network.cancel(requestID)
Dunno if it’s necessary or not, but removing it cured the crash.
rob
January 1, 2016, 11:25pm
5
Yea, you shouldn’t cancel an event from its call back listener. You should wrap the call in a timer call:
timer.performWithDelay(10, function() network.cancel( requestID ); end)
Rob