// Check the network connection status, Monitor network connections (Wi-Vi, GPRS, UMTS, etc .)
Public static boolean checkNetWorkStatus (Context context ){
Boolean result;
ConnectivityManage cm = (ConnectivityManager) context. getSystemService (Context. CONNECTIVITY_SERVICE );
NetworkInfo netinfo = cm. getActiveNetworkInfo ();
If (netinfo! = Null & netinfo. isConnected ()){
Result = true;
Log. I (TAG, "The net was connected ");
} Else {
Result = false;
Log. I (TAG, "The net was bad! ");
}
Return result;
}
Check whether the URL is valid.
Public static boolean checkURL (String url ){
Boolean value = false;
Try {
HttpURLConnection conn = (HttpURLConnection) new URL (url). openConnection ();
Int code = conn. getResponseCode ();
System. out. println (">>>>>>>>>>>>>>>>>" + code + "< <");
If (code! = 200 ){
Value = false;
} Else {
Value = true;
}
} Catch (MalformedURLException e ){
// TODO Auto-generated catch block
E. printStackTrace ();
} Catch (IOException e ){
// TODO Auto-generated catch block
E. printStackTrace ();
}
Return value;
}
 
Author "AndroidPlayer"