cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon MacDonald (JIRA)" <>
Subject [jira] [Commented] (CB-1269) navigator.onLine and related events never fire on Android
Date Tue, 21 Aug 2012 17:53:38 GMT


Simon MacDonald commented on CB-1269:

Hey Andrew,

I think you mean to use:

document.addEventListener('online', onLineEvent2, false);
document.addEventListener('offline', onLineEvent2, false);

If you switch to that you will get the events.

The other thing you will run into is that navigator.onLine is always true in the Android WebView.
That's a bug in the OS as near as I can tell.
> navigator.onLine and related events never fire on Android
> ---------------------------------------------------------
>                 Key: CB-1269
>                 URL:
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 2.0.0
>            Reporter: Andrew Grieve
>            Assignee: Andrew Grieve
> Discovered this when doing bridge testing. 
> function onLineEvent2(e) {
>     console.log('Got online=' + navigator.onLine);
> }
> window.addEventListener('online', onLineEvent2, false);
> window.addEventListener('offline', onLineEvent2, false);
> The events never fire when I put my phone in and out of airplane mode. I see the following
> 08-21 13:20:14.095: D/DroidGap(12652): onMessage(networkconnection,none)
> But never get an online/offline event.
> If I use setNetworkAvailable() manually, the events get fired as a result. This leads
me to believe that it's the app's responsibility to call this setter in order for the events
to be fired.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message