cordova插件(plug-in)怎么使用?需不需要引入?

我想用cordova做做一个hybridAPP,希望app启动时自动检测网络是否连接,于是乎添加了这个插件:

cordova plugin add cordova-plugin-network-information

参考链接-来自npm

然后在index.js里加上了如下的代码,并且引入了jQuery.js:

$(document).ready(function () {
    function checkConnection() {
        var networkState = navigator.connection.type;

        var states = {};
        states[Connection.UNKNOWN]  = 'Unknown connection';
        states[Connection.ETHERNET] = 'Ethernet connection';
        states[Connection.WIFI]     = 'WiFi connection';
        states[Connection.CELL_2G]  = 'Cell 2G connection';
        states[Connection.CELL_3G]  = 'Cell 3G connection';
        states[Connection.CELL_4G]  = 'Cell 4G connection';
        states[Connection.CELL]     = 'Cell generic connection';
        states[Connection.NONE]     = 'No network connection';

        alert('Connection type: ' + states[networkState]);
    }

    checkConnection();
});

然后生成app:

cordova build android

但是生成的AndroidAPP在启动后并不能alert网络状态,是不是plug-in也需要在index.html中引入?如果是的话该怎么引入?

谢谢

查看回复