I use webviews in my app, but when I start my app with a bad internet connection I cannot use webviews without error until I restart the app, regardless of my connection at the time. I use the following code:
[lua]
local function webListener( event )
if event.url then
print( "You are visiting: " … event.url )
end
if event.type then
print( "The event.type is " … event.type ) – print the type of request
end
if event.errorCode then
native.showAlert( “Error!”, event.errorCode … “: This feature requires an internet connection. There was an issue connecting to the internet. Please make sure that you are connected and try again.”, { “OK” }, closePress )
end
end
local webView = native.newWebView( display.contentCenterX, TRUE_TOP + 80, TRUE_WIDTH, TRUE_HEIGHT - 80)
webView.anchorY = 0
webView:addEventListener( “urlRequest”, webListener )
webView:request( URL )
[/lua]
I receive the following error:
“-1002: This feature requires an internet connection. There was an issue connecting to the internet. Please make sure that you are connected and try again.”
To reproduce this error, I simply have to turn on airplane mode on my phone, open the app, turn off airplane mode, and try to open any webview.
I have also checked the value of “network.canDetectNetworkStatusChanges,” which is “true.”