Thursday, 14 April 2011

WP7 Network Connection Check

Not everyone can have instant internet network access on the Windows Mobile 7, so here I will give a really quick pointer to how you can code to check network connection, in the namespace there is Microsoft.Phone.Net.NetworkInformation; 

You can then use this namespace, to run the method that checks if a network connection is available via a boolean accessor done via: -

if (NetworkInterface.GetIsNetworkAvailable())

{

    Do some conection stuff or alert here…

}

or alternatively, you can write: -

bool hasNetworkConnection =
NetworkInterface.NetworkInterfaceType != NetworkInterfaceType.None;

It is as simple as that using one linr of code for a bollean check, hope that helps!!

No comments: