hotspot以编程方式设置用户数

时间:2017-11-28 12:20:17

标签: android android-wifi hotspot

我使用了一种创建热点的方法并且它正在运作

但我需要设置将在此热点中的特定数量的最大连接

提前致谢

我目前的代码:

private boolean configHotspot(String name,String pass) {
    WifiConfiguration wifiCon = new WifiConfiguration();
    wifiCon.SSID = name;
    wifiCon.preSharedKey = pass;
    wifiCon.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
    wifiCon.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
    wifiCon.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
    wifiCon.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
    try
    {
        Method setWifiApMethod = wifimanager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class);
        boolean apstatus=(Boolean) setWifiApMethod.invoke(wifimanager, wifiCon,true);
        return apstatus;
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return false;
}

0 个答案:

没有答案