Method 1:
[Java]
ConnectivityManager manager = (ConnectivityManager) getSystemService (Context. CONNECTIVITY_SERVICE );
NetworkInfo info = manager. getActiveNetworkInfo ();
If (info! = Null & info. isConnected ()){
Return true;
} Else {
Return false;
}
Method 2:
[Java]
TelephonyManager manager = (TelephonyManager) getSystemService (Context. TELEPHONY_SERVICE );
Int state = manager. getDataState ();
If (state = TelephonyManager. DATA_CONNECTED ){
Urn true;
} Else {
Urn false;
}
Method 1: You can check the mobile phone connection or the wireless connection status of the mobile phone.
Method 2: Check the connection status of the mobile phone only. Do not check the wireless connection status of the mobile phone. (that is, if the mobile phone does not have a mobile phone card, but the wireless connection status does not exist, false is returned)
From the Central-Perk Column