Wednesday, August 10, 2011

Checking Internet Connection in Android

private boolean checkInternetConnection() {

ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (conMgr.getActiveNetworkInfo() != null
&& conMgr.getActiveNetworkInfo().isAvailable()
&& conMgr.getActiveNetworkInfo().isConnected()) {

//tryLogic;
return true;

} else {

Toast.makeText(Login.this, “Internet Connection Not Present”, Toast.LENGTH_LONG).show();
Log.v(TAG, “Internet Connection Not Present”);
return false;

}
}

No comments:

Post a Comment