my first time experimenting with Apache Cordova 3.0.
downloaded lib, unziped cordova-android and cordova-js and created a project:
./create ~/Documents/andriod-projects/HelloWorld com.x.HelloWorld HelloWorld
- OK
res/xml/config.xml
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager" />
AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
on index.js device ready:
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
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("Network: "+states[networkState]);
}
when I emulate the project on my andriod I got in LogCat Error:Connection is not defined
:
what I am missing? I have to attach a .js in order to Connection be declared?