Connectivitymanager cm = (Connectivitymanager) getsystemservice (Context.connectivity_service);
Get the Networkinfo object that represents the networked state
Networkinfo wifiinfo = Cm.getnetworkinfo (Connectivitymanager.type_wifi);
return wifiinfo! = null && wifiinfo.isconnected ()
True is the WiFi environment, and can be used normally, otherwise WiFi is not available
Connectivitymanager main management and network connection related operations
The Networkinfo class contains a detailed description of the WiFi and mobile two network mode connections, and the state object obtained through its GetState () method represents
The status of the connection success or not.
- /Jump to the wireless network Settings screen
- StartActivity (new Intent (Android.provider.Settings.ACTION_WIRELESS_SETTINGS));
- //Jump to the unlimited WiFi network Settings screen
- StartActivity (new Intent (Android.provider.Settings.ACTION_WIFI_SETTINGS));
Context context = Mainactivity.getapplicationcontext ();//Get Application context
Connectivitymanager Connectivitymanager = ( Connectivitymanager) Context
. Getsystemservice (Context.connectivity_service);//Get the system's connection service
Networkinfo Networkinfo = Connectivitymanager.getactivenetworkinfo ();//Gets the connection condition of the network
if ( networkinfo.gettype () = = Connectivitymanager.type_wifi) {
//determine WIFI network
}else if ( networkinfo.gettype () ==connectivitymanager.type_ MOBILE) {
//judging 3G net
}