Phonegap (online build) app - no internet connection and network status

前端 未结 2 584
庸人自扰
庸人自扰 2020-12-17 23:03

My first jquery mobile app contains elements which needs datas from Internet sources like public Google calendars and Amazon affiliate widgets but it works only when I testi

2条回答
  •  醉梦人生
    2020-12-17 23:18

    For checking internet connection I use this function:

    function checkConnection(){
                var networkState = navigator.connection.type;
                if(Connection.NONE==networkState)
                    return "

    No connection

    "; }

    For being able yo use it you have to add the network state plugin this way:

    cordova plugin add cordova-plugin-network-information
    

    Your AndoidManifest file should include this two lines:

    
    
    

提交回复
热议问题