Android Check to be able to surf

Source: Internet
Author: User

/** * 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.