Android gets a summary of the current mobile phone networking method

Source: Internet
Author: User

 

The Android platform provides a wide range of Network Interfaces. It is even more difficult to obtain the network access method set by the mobile phone, so it is very convenient for development.
Activity provides the ConnectivityManager interface for obtaining the network management class. You can use ConnectivityManager to obtain the Network Information Class NetworkInfo. NetworkInfo contains a lot of network information. Example code:


// Obtain the Network Connection Manager
ConnectivityManager connectionManager = (ConnectivityManager)
GetSystemService (CONNECTIVITY_SERVICE );
// Obtain the network status information in the following three methods:
NetworkInfo networkInfo = connectionManager. getActiveNetworkInfo ();
NetworkInfo has the following methods:
GetDetailedState (): Get the detailed status.
GetExtraInfo (): Get additional information.
GetReason (): Get the reason for connection failure.
GetType (): gets the network type (generally mobile or Wi-Fi ).
GetTypeName (): Get the network type name (generally set to "WIFI" or "MOBILE ").
IsAvailable (): determines whether the Network is available.
IsConnected (): determines whether a connection is established.
IsConnectedOrConnecting (): determines whether a connection is established or is in progress.
IsFailover (): determines whether the connection fails.
IsRoaming (): determines whether to roam
When using wifi
GetType is WIFI
GetExtraInfo is empty.
GetType is MOBILE

Using mobile CMNET
The value of getExtraInfo is cmnet.
Mobile CMWAP
The value of getExtraInfo is cmwap, but it cannot be accessed by a common website without a proxy.
3gwap connection
The value of getExtraInfo is 3 gwap.
Using China Unicom ipvnet
The value of getExtraInfo is 3 gnet.
Using Unicom uniwap
The value of getExtraInfo is uniwap.
Using Unicom uninet
The value of getExtraInfo is uninet.

To be determined by Telecom
The following solutions

 

Author: Liu Yafei

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.