is Wifi Connected - Android android.net.wifi

Android examples for android.net.wifi:Wifi State

Description

is Wifi Connected

Demo Code

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main{

    public static boolean isWifiConnected(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo wifiNetworkInfo = connectivityManager
                .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        if (wifiNetworkInfo.isConnected()) {
            return true;
        }/*from  ww  w. j av a  2 s .  c  o  m*/
        return false;
    }

}

Related Tutorials