Last Updated: February 25, 2016
·
1.245K
· jmpergar

Check WIFI connection

ConnectivityManager connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
boolean wifiConnected = mWifi.isConnected();

This permission is necessary:

android.permission.ACCESS_NETWORK_STATE

1 Response
Add your response

I have here this other snippet for check if exist one active and connected only.

private boolean isNetworkEnabled() {
    ConnectivityManager conMgr = (ConnectivityManager) mActivity.getSystemService(
            Context.CONNECTIVITY_SERVICE);
    NetworkInfo i = conMgr.getActiveNetworkInfo();
    if (i == null || !i.isConnected() || !i.isAvailable()) {
        return false;
    }
    return true;        
}
over 1 year ago ·