Applications can use the Netstatus API to detect if the network is on or off.
The following is an example of how to use the API (however, ensure you call the update()
private static final NetStatusMonitor _monitor = new NetStatusMonitor();
//network is off
If your system is connected using a device emulator, such as VMWare, or other connections that share your LAN or wireless network connection, the netstatus API always returns true
, even after you disconnect the LAN cable and wireless. This is because of the existence of the virtual adaptor. If you want your application to be notified of a true offline state (or plan to disconnect the system), go to Start > My Network Places
, right-click on Properties
, and disable the shared connections.
Parent topic: Developing network aware application logic: XPD622