/** * Test Connectivitymanager * Connectivitymanager main management and network connection related operations * related Telephonymanager management and mobile phone, carrier and other related information; Wifimanager Manage and WiFi-related information. * To access network status, first add permissions <uses-permission android:name= "Android.permission.ACCESS_NETWORK_STATE"/> * The Networkinfo class contains a detailed description of the WiFi and mobile two network mode connections, and the state object obtained by its GetState () method represents the status of the success of the connection or not. * */ Public voidTestconnectivitymanager () {Connectivitymanager Connmanager= (Connectivitymanager) This. Getsystemservice (Connectivity_service); //get the Networkinfo object that represents the networked stateNetworkinfo Networkinfo =Connmanager.getactivenetworkinfo (); //gets whether the current network connection is availableBoolean available =networkinfo.isavailable (); if(available) {LOG.I ("Notice","The current network connection is available"); } Else{log.i ("Notice","The current network connection is available"); } State State=Connmanager.getnetworkinfo (connectivitymanager.type_mobile). GetState (); if(state.connected==State ) {LOG.I ("Notice","GPRS network is connected"); } State=Connmanager.getnetworkinfo (Connectivitymanager.type_wifi). GetState (); if(state.connected==State ) {LOG.I ("Notice","WiFi network is connected"); } //Jump to the wireless network Settings screenStartActivity (NewIntent (Android.provider.Settings.ACTION_WIRELESS_SETTINGS)); //jump to the unlimited WiFi network Settings screenStartActivity (NewIntent (Android.provider.Settings.ACTION_WIFI_SETTINGS)); }
Android Check to be able to surf