I know there is a lot of questions and answers about this in Stackoverflow, I read a lot of them, but none of them work.
I clarified in the title Androi
Apache Cordova (was called PhoneGap) is an open-source mobile development framework. It allows you to use standard web technologies - HTML5, CSS3, and JavaScript for cross-platform development. Applications execute within wrappers targeted to each platform, and rely on standards-compliant API bindings to access each device's capabilities such as sensors, data, network status, etc.
document reference cordova
In your problem (Option 1):
navigator.onLine
...is not working because (on android) it is broken {the "raw" version, Cordova enabled webview is different}(as you have found out), you have to built your WebView App with the Cordova Framework. Cordova was developed EXACTLY to solve this problem. The GAP in PhoneGap is the gap between the "virtual machine", "sandbox" and access to the hardware, AND it's cross-platform.
Android Permissions: app/AndroidManifest.xml
Cordova Permissions: app/res/xml/config.xml
Cordova installationhttps://cordova.apache.org/docs/en/latest/guide/cli/
https://nodejs.org/en/download/
node-v4.5.0-x86.msi
success.
C:\>npm install -g cordova
And away you go!
I have built your code into cordova, I'm getting there (hopefully, hard problem), here's some image's of what I have so far [not in WebView exactly yet, {see the navigator.userAgent output in the second image}] (notice the event listener is working ;O), but not good enough:o( ).