Issue
I am trying to connect to a device via wifi
final WifiNetworkSpecifier wifiNetworkSpecifier = new WifiNetworkSpecifier.Builder()
.setSsidPattern(new PatternMatcher(networkSSIDPattern, PatternMatcher.PATTERN_PREFIX))
.setWpa2Passphrase(passWord)
.build();
final NetworkRequest networkRequest = new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.setNetworkSpecifier(wifiNetworkSpecifier)
.build();
connectivityManager = (ConnectivityManager) RainBird.getContext().getApplicationContext().getSystemService(CONNECTIVITY_SERVICE);
connectivityManager.requestNetwork(networkRequest, networkCallback);
I am getting a dialog with the good device network, after connecting, the same network appears two times in the dialog.
how can I fix it?
after one connection, the same network appears 2 times:
The problem only occurs on android12
Solution
Finally, I found the solution I just changed compileSdkVersion from 30 to 31
ConnectivityManager in android 12 (version 31) contain the fix
thank you every one
Answered By - haythem souissi
Answer Checked By - Candace Johnson (JavaFixing Volunteer)