Following the Android documentation, I'm using this code to connect programmatically to a specific SSID:
private void connectToAP(String ssid, String password) {
...
WifiNetworkSpecifier wifiNetworkSpecifier = new WifiNetworkSpecifier.Builder()
.setSsid(ssid)
.setWpa2Passphrase(password)
.build();
NetworkRequest.Builder requestBuilder = new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.setNetworkSpecifier(wifiNetworkSpecifier);
NetworkRequest request = requestBuilder.build();
connManager.requestNetwork(request, myNetworkCallback);
...
bindNetwork(); //this method will bind the network without internet
}
as described in the documentation https://developer.android.com/guide/topics/connectivity/wifi-bootstrap#bypass-approval, if I don't forget the network, the second connection to that specific SSID have to bypass the user approval.
My problem is this:
What I'm doing wrong?
here I attach a example for you val specifier, observe that the magic for this is at put in setBssid a value, with it thats ok and the system don`t show window aproval.
WifiNetworkSpecifier = if(isDevice8424){
WifiNetworkSpecifier.Builder()
.setSsid(ssid)
.setBssid(MacAddress.fromString(bssid))//here ir the magic!
.build()