diff --git a/plugin.xml b/plugin.xml index e2b26af..15eab40 100644 --- a/plugin.xml +++ b/plugin.xml @@ -9,6 +9,11 @@ id="org.apache.cordova.core.NetworkManager" + + + + + @@ -23,7 +28,7 @@ id="org.apache.cordova.core.NetworkManager" - + diff --git a/src/android/NetworkManager.java b/src/android/NetworkManager.java index 6853c8d..dd2bf31 100755 --- a/src/android/NetworkManager.java +++ b/src/android/NetworkManager.java @@ -22,6 +22,7 @@ import org.apache.cordova.api.CallbackContext; import org.apache.cordova.api.CordovaInterface; import org.apache.cordova.api.CordovaPlugin; import org.apache.cordova.api.PluginResult; +import org.apache.cordova.CordovaWebView; import org.json.JSONArray; import android.content.BroadcastReceiver; diff --git a/www/Connection.js b/www/Connection.js new file mode 100644 index 0000000..f20a485 --- /dev/null +++ b/www/Connection.js @@ -0,0 +1,34 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +/** + * Network status + */ +module.exports = { + UNKNOWN: "unknown", + ETHERNET: "ethernet", + WIFI: "wifi", + CELL_2G: "2g", + CELL_3G: "3g", + CELL_4G: "4g", + CELL:"cellular", + NONE: "none" +}; diff --git a/www/network.js b/www/network.js index 63736a9..ccb8556 100644 --- a/www/network.js +++ b/www/network.js @@ -1,5 +1,4 @@ /* - * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -51,6 +50,9 @@ var me = new NetworkConnection(); var timerId = null; var timeout = 500; +channel.createSticky('onCordovaConnectionReady'); +channel.waitForInitialization('onCordovaConnectionReady'); + channel.onCordovaReady.subscribe(function() { me.getInfo(function(info) { me.type = info;