From: http://blog.csdn.net/xxxsz/article/details/8199031
Determine whether the network type is WiFi, 3G, or 2G network, and perform different processing on different networks. Now we will sort out the judgment methods for your reference: I have tested the data Mobile 2g, China Unicom 2g, China Unicom 3G, and WiFi used below. Currently, I have no telecom card, so I have not verified it. I have a colleague from China Telecom mobile phone, you can verify the result and send it to you. Connectivitymanager connectmgr = (connectivitymanager) This. getsystemservice (context. connectivity_service); networkinfo info = connectmgr. getactivenetworkinfo (); 1. Determine whether the network is WiFi. before determining whether the network is WiFi, you must perform a non-null judgment. If no network connection is available, info = nullinfo. getType () = connectivitymanager. type_wifi 2. Determine if it is a mobile phone network info! = NULL & info. getType () = connectivitymanager. type_mobile phone network: info. getsubtype () Here getsubtype () is used, instead of GetType (), GetType () returns 0, or 1, which indicates whether it is a mobile phone network or WiFi info. the getsubtype () Value List is as follows: * network_type_cdma network type: CDMA * network_type_edge network type: edge * Listen network type: evdo0 * Listen network type: evdoa * network_type_gprs network type: GPRS * network_type_hsdpa network type: HSDPA * network_type_hspa network type for HSPA * network_type_hsupa, the network type is hsupa * network_type_umts, and the 3G network type of UMTS Unicom is UMTS or HSDPA, 2g of China Mobile and China Unicom is GPRS or edge, 2g of China Telecom is CDMA, and 3g of China Telecom is evdo