[Android] network connection types and channels, android Channels
1. Implementation Method
1.1 Use HttpUrlConnection
1.2 use HttpClient
1.3 Use Socket, such as pea pods and chat tools
2. Communication channels
2.1 WLAN (Wi-Fi), around 100 meters of Data Transmission
2.2 Mobile Phone APN Access Point (Base Station)
2.2.1 The wap method is China's characteristic. First, it will connect to the telecom operator's proxy to intercept 10.0.0.172, and HttpUrlConnection will be unstable.
2.2.2 net method
3. Communication Tools
3.1 determine the network type
Based on the Context, determine whether it is wifi or APN, and then determine the access method of APN. If there is proxy information, wap does not have some net.
Package com.tsh.lottery.net; import android. content. contentResolver; import android. content. context; import android. database. cursor; import android.net. connectivityManager; import android.net. networkInfo; import android.net. uri; public class NetUtils {/*** get network status * @ param context * @ return */public static String getNetworkInfo (Context context) {ConnectivityManager cm = (ConnectivityManager) context. getS YstemService (Context. CONNECTIVITY_SERVICE); // judge wifi NetworkInfo networkInfo = cm. getNetworkInfo (ConnectivityManager. TYPE_WIFI); if (networkInfo! = Null & networkInfo. isConnected () {return "wifi" ;}// you can determine the APN NetworkInfo mobileInfo = cm. getNetworkInfo (ConnectivityManager. TYPE_MOBILE); if (mobileInfo! = Null & mobileInfo. isConnected () {// obtain the access method of the APN. Due to permission issues, the access method fails. // ContentResolver resolver = context. getContentResolver (); // Cursor cursor = resolver. query (Uri. parse ("content: // telephony/carriers"), null); // if (cursor! = Null & cursor. moveToFirst () {// String proxy = cursor. getString (cursor. getColumnIndex ("proxy"); // System. out. println (proxy); //} return "mobile";} return "no ";}}