is Wifi Available - Android android.net.wifi

Android examples for android.net.wifi:Wifi State

Description

is Wifi Available

Demo Code

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;

public class Main{

    public static boolean isWifiAvailable(Context context) {
        ConnectivityManager conMan = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        State wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
                .getState();// w  ww.j a  va  2s  .  co  m
        if (State.CONNECTED == wifi) {
            return true;
        } else {
            return false;
        }
    }

}

Related Tutorials