phonegap/phonegap-android — Issue #277: On application start, offline event is triggered for connected device.
Author: angelo0000
Created: 2011-10-21 15:19:30+00:00
State: open

We are using Phonegap 1.0 and have been doing some testing of our application on an LG Thrill which runs Android 2.2.2.

We attach to the 'offline' event as described in the phonegap documentation but intermittently we receive the offline event on app start and never receive the online event after.

As a temporary fix we do this:

document.addEventListener("offline", function(){
setTimeout(function(){
networkState = navigator.network.connection.type;
if(networkState == Connection.UNKNOWN || networkState == Connection.NONE) {
tcApp.setOffline();
}
}, 3000);
}, false);

We basically now listen for your event and delay our action for 3 seconds so that we can ask you for your final answer.

Expectation:
When the app loads, we only get an offline event if the phone has no network connectivity.