Hello Given link question is just showing how to turn on/off wifi hotspot but i want to add create wifi hotspot with SSID and password. I written code for creating wifihotspot(in both NONE and WPA2 PSK) in android and its working fine upto android 7 but in oreo it returning me false value.The summary of my code is-
private WifiManager wifiManager;
private Method method;
private WifiConfiguration config;
config.SSID = ssid;
config.status = WifiConfiguration.Status.ENABLED;
method = wifiManager.getClass().getMethod("setWifiApEnabled",
WifiConfiguration.class, Boolean.TYPE);
boolean status = (Boolean) method.invoke(wifiManager, config, true);
So my question is how to create wifihotspot in both NONE and WPA2 PSK format for android oreo? Is it possible?
The
setWifiApEnabled
will be deprecated. Looking at the source code, it always returns false :You can try using
ConnectivityManager#startTethering(int, boolean, ConnectivityManager#OnStartTetheringCallback)
as said in the javadoc. I personnally never tried it.Oreo doesnot support to create hotspot programmatically with no password. It always creates hotspot with unique ssid and key generated randomly.