Home > Mobile >  Android 10 designated wifi connection, on huawei mobile phones don't fit
Android 10 designated wifi connection, on huawei mobile phones don't fit

Time:10-08

Project in the process of adaptation Android 10 found that the same code is running normally on the oppo and a mobile phone, on huawei mobile phone test, found that after the popup window click on the designated wifi connection, the system will immediately switch wifi, pop-up window will pop up again at the bottom of the
 public void changeToWifiQ (Context Context, final String wifiName, String wifiPwd) {
If (Build) VERSION) SDK_INT & gt;=Build. VERSION_CODES. Q) {
NetworkSpecifier specifiers=
New WifiNetworkSpecifier. Builder ()
SetSsidPattern (new PatternMatcher (wifiName, PatternMatcher PATTERN_PREFIX))
. SetWpa2Passphrase (wifiPwd)
.build();

NetworkRequest request=
New NetworkRequest. Builder ()
AddTransportType (NetworkCapabilities. TRANSPORT_WIFI)
_CAPABILITY_INTERNET removeCapability (NetworkCapabilities.NET)
. SetNetworkSpecifier (specifiers)
.build();

ConnectivityManager ConnectivityManager=(ConnectivityManager)
The context. GetSystemService (context. CONNECTIVITY_SERVICE);

ConnectivityManager.Net workCallback networkCallback=new ConnectivityManager.Net workCallback () {
@ Override
Public void onAvailable Network (Network) {
//do success processing here..
}

@ Override
Public void onUnavailable () {
//do failure processing here..
}
};
ConnectivityManager. RequestNetwork (request, networkCallback);
}
}

use the above code in huawei mobile phone connection above will repeat the popup window
  • Related