Trying to get an access point set up on Android 7.1 using setWifiApEnableMethod
with all required permissions granted,
public static boolean createWAP(final WifiManager wifiManager, String apName) {
final WifiConfiguration netConfig = new WifiConfiguration();
netConfig.SSID = apName;
netConfig.hiddenSSID = false;
netConfig.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
netConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
netConfig.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
netConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
try {
final Method setWifiApMethod = wifiManager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class);
boolean apstatus = (Boolean) setWifiApMethod.invoke(wifiManager, null, true);
Log.d(TAG, "WAP created: " + apstatus);
return apstatus;
} catch (Exception e) {
Log.d(TAG, "WAP creation failed: " + e);
}
return false;
}
This function creates the access point and the access point is discoverable from other devices. However, other devices are not able to connect to the WAP created. It gets stuck at Obtaining IP address...
. When I try to connect to the WAP from desktop, the desktop self assigns an IP.
When the same hot spot is enabled from the settings manually then other devices are able to connect to the WAP without any problem.
Assuming tha the DHCP server is not getting started? Is there any additional step required to start the DHCP server after enabling the access point?