Checking for a network
When you start working with your mobile devices, you can't always take the network's presence for granted. The signal may be nonexistent or it may be very weak, or the user might switch from cellular network to WiFi or back again. But now the PhoneGap API includes a connection Object, which gives you access to the device's cellular and WiFi connection information.
Determining the Connection Type
If you want to find out the connection information of your Windows Phone using PhoneGap you can use the connection object. An example:
function checkConnection()
{
var networkState = navigator.network.connection.type; //return a specific state
}
Here the navigator.network.connection.type - lets the developers know about the current device's connection states and in simple terms lets you know the type of connection that your Windows Phone is using.
The connection.type function will return one of a possible list of connection types available:
- Connection.UNKNOWN
- Connection.ETHERNET
- ConnectionCELL_2G
- ConnectionCELL_3G
- ConnectionCELL_4G
- ConnectionNONE
It's a good idea to dress up these messages by providing users with a customer's information.function checkConnection()
For example
{
var networkState = navigator.network.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.NONE] = 'No network connection';
alert('Connection type: ' + states[networkState]);
}To determine what kind of connection can be made, we will be using connection.type. For example, if the connection type were NONE, then the alert box would contain the message No network connection.
Checking Network Availability

Vijay PrativadiPosted Jan 31, 2012, 12:52 AM
Very Good!! Keep Posting More
Aaron CronjePosted Jan 30, 2012, 11:49 PM
It's really a great stuff to accomplish such task keep going and thanks sharing.....