I need to make my app connect automatically to specific SSID
with password.
I'm trying this but this is what I get:
error:
non-static method addNetwork(WifiConfiguration) cannot be referenced from a static context
error:
non-static method enableNetwork(int,boolean) cannot be referenced from a static context
final WifiManager wifiManager = (WifiManager) MainActivity.this.getSystemService(Context.WIFI_SERVICE);
final WifiConfiguration config = new WifiConfiguration();
config.SSID = "\"xxx\"";
config.preSharedKey = "\"123\"";
if (!wifiManager.isWifiEnabled()){
wifiManager.setWifiEnabled(true);
int networkId = WifiManager.addNetwork(config);
WifiManager.enableNetwork(networkId, true);
}