WiFi错误密码返回true

时间:2017-12-21 12:08:56

标签: android android-wifi android-connectivitymanager

我正在尝试在我的设备上添加wifi网络

$(document).ready(function() {

    $('#calendar').fullCalendar({
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay,listWeek'
      },


      defaultDate: '2017-12-12',
      navLinks: true, // can click day/week names to navigate views
      businessHours: true, // display business hours
      editable: true,
      eventLimit: true, // allow "more" link when too many events

无论密码是什么,它都会返回true。

然后我检查了互联网连接或不喜欢这个

 public static boolean connectToWifi(String ssid, String password) {
    WifiConfiguration wifiConfig = new WifiConfiguration();

    wifiConfig.SSID = String.format("\"%s\"", ssid);
    wifiConfig.preSharedKey = String.format("\"%s\"", password);

    WifiManager wifiManager = (WifiManager) getContext().getApplicationContext().getSystemService(WIFI_SERVICE);
    assert wifiManager != null;
    wifiManager.setWifiEnabled(true);
    int netId = wifiManager.addNetwork(wifiConfig);
    wifiManager.disconnect();
    wifiManager.enableNetwork(netId, true);

    return wifiManager.reconnect();

}

但如果我添加了错误的密码,它也会返回true 那么请你在这个问题上纠正我。

0 个答案:

没有答案