//determine if the WiFi connection is public boolean iswificonnected (Context context ) { if (context != null) { connectivitymanager mconnectivitymanager = (Connectivitymanager) context .getsystemservice (Context.CONNECTIVITY_SERVICE); networkinfo mwifinetworkinfo = mConnectivityManager .getnetworkinfo (Connectivitymanager.type_wifi); if (mwifinetworkinfo != null) {     &NBsp; return mwifinetworkinfo.isavailable (); } } return false; } //determine if the network connection is normal public boolean isnetworkconnected (Context context) { if (context != null) { connectivitymanager mconnectivitymanager = (Connectivitymanager) context .getsystemservice ( Context.connectivity_service); Networkinfo mnetworkinfo = mconnectivitymanager .getactivenetworkinfo (); if (mnetworkinfo != null) { return mnetworkinfo.isavailable (); } } return false; } / /Determine network connection type public static int getconnectedtype (context context) { if (context != null) { connectivitymanager mconnectivitymanager = (Connectivitymanager) context .getsystemservice (Context.connectivity_service); NetworkInfo mNetworkInfo = mConnectivityManager . Getactivenetworkinfo (); if ( Mnetworkinfo != null && mnetworkinfo.isavailable ()) { return mnetworkinfo.gettype (); } } return -1; } //Determine the SIM card type of the mobile phone public static string get (Context Context) { TelephonyManager telManager = ( Telephonymanager) context .getsystemservice (Context.telephony_service); string operator = telmanager.getsimoperator (); if (operator != null) { if (Operator.equals ("46000") | | operator.equals ("46002")) { // China Mobile return "Move"; } else if (Operator.equals ("46001")) { return "Unicom"; // China Unicom } else if (Operator.equals ("46003") ) { return "Telecommunications"; // China Telecom } } return ""; } //determine whether the phone can be normal internet ping, even if the phone is connected to the WiFi (hotspot no internet), mobile phone or not online &nBsp;private static final boolean ping () { string result = null; try { String ip = "www.baidu.com";// Unless Baidu hangs, otherwise use this should be no problem ~ process p = Runtime.getruntime (). EXEC ("ping -c 3 -w 100 " + ip)//ping3 times // read the contents of ping without adding. inputstream input = p.getinputstream (); BufferedReader in = new BufferedReader (New inputstreamreader (input)); Stringbuffer stringbuffer = new stringbuffer (); string content = ""; while ((Content = in.readline ()) != null) { stringbuffer.append (content); }          LOG.I ("TTT", "result content : " + stringbuffer.tostring ()); // ping status int status = p.waitfor (); if (status == 0) { result = "successful~"; return true; } else { result = "failed~ Cannot reach the ip address "; } } catch (ioexception e) { result = "Failed~ ioexception"; } catch ( Interruptedexception e) { result = "Failed~ interruptedexception"; } finally {     LOG.I ("TTT", "result = " + result); } return false; }
Can be used in combination with the above methods to achieve their own needs. The first blog post!!!!!!
Good Kai Sen!!!!!!!!! There's wood and!!!!!!!!!!!!!!!!!!!!. Ah, haha,!!!!!!!. Will someone find me/doubt/nose