Check if Wifi has Password - Android Wifi

Android examples for Wifi:Wifi Connection

Description

Check if Wifi has Password

Demo Code


//package com.java2s;

import android.net.wifi.WifiConfiguration;

import android.text.TextUtils;

public class Main {
    public static boolean hasPassword(WifiConfiguration wifiConfig) {
        if (wifiConfig == null) {
            return true;
        }//  w  w w  .java  2s.  co  m
        return !TextUtils.isEmpty(wifiConfig.preSharedKey)
                || !TextUtils.isEmpty(wifiConfig.wepKeys[0])
                || !TextUtils.isEmpty(wifiConfig.wepKeys[1])
                || !TextUtils.isEmpty(wifiConfig.wepKeys[2])
                || !TextUtils.isEmpty(wifiConfig.wepKeys[3]);
    }
}

Related Tutorials