How To check Internet Connection?


private boolean checkInternetConnection() {

ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

// ARE WE CONNECTED TO THE NET

if (conMgr.getActiveNetworkInfo() != null

&& conMgr.getActiveNetworkInfo().isAvailable()

&& conMgr.getActiveNetworkInfo().isConnected()) {

return true;

} else {

// Log.v(TAG, "Internet Connection Not Present");

return false;

}

}


<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Comments

Popular posts from this blog

Bluetooth Data Transfer Example

DeCompile .apk file on ubuntu 14.04