WifiManager.getConfiguredNetworks always returns empty list

后端 未结 3 711
暖寄归人
暖寄归人 2021-01-23 14:51

I am trying to connect to an open wifi network. When I open my app it should turn on wifi and connect to the network defined as below. The problem is that WifiManager.getC

3条回答
  •  再見小時候
    2021-01-23 15:39

    Try to comment these lines in your code.. do you see any change in result set?

    wifiManager.setWifiEnabled(true);   
    wifiManager.addNetwork(conf);
    

    You might want to check the return for wifiManager.addNetwork(conf);, is it returning -1.

    For me this lines return 31 objects only.. no idea why..still hunting for it.

    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    List arraylist = wifiManager.getConfiguredNetworks();
    Log.wtf("WifiPreference","No of Networks"+arraylist.size());
    

提交回复
热议问题