Home > Mobile >  Android wifi problem to answer!!!!!!!!!!!!!!!!!!!! Thank you very much
Android wifi problem to answer!!!!!!!!!!!!!!!!!!!! Thank you very much

Time:09-18




Network is wifi, and I'm bindProcessToNetwork (network); But why connectivityManager. GetNetworkInfo (connectivityManager. GetActiveNetwork ()). GetTypeName () or return to the mobile


There's just one problem: my app has a function, sweep through code to connect wifi, scanning can be successful, but the wifi can only be used within my app, other app, or mobile browser cannot use the sweep through code to add the wifi, does anyone know why? (10) android

The code is as follows:

NetworkSpecifier specifiers=
New WifiNetworkSpecifier. Builder ()
SetSsidPattern (new PatternMatcher (ssid, PatternMatcher PATTERN_PREFIX))
. SetWpa2Passphrase (password)
.build();

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

Final 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..
The d (TAG, "onAvailable:" + network);
Super. OnAvailable (network);
//network. GetSocketFactory ();
Network. GetSocketFactory LogUtil. E (" () ", the network. The getSocketFactory () + "-- -- -- -- -- -- -- & gt;" );
Boolean b=connectivityManager. BindProcessToNetwork (network);
ConnectivityManager. GetAllNetworks ();
ConnectivityManager. GetActiveNetwork ();
//connectivityManager. GetNetworkInfo (connectivityManager. GetActiveNetwork ()). GetTypeName ();
LogUtil. E (" qwe "b +" -- -- -- -- -- -- -- & gt;" );
.//a Boolean q=wifiManager saveConfiguration ();
//LogUtil. E (" qwe ", q + "-- -- -- -- -- -- -- & gt;" );
//connectivityManager. UnregisterNetworkCallback (this);
}

/* *
* network is unavailable to invoke and onAvailable paired
*/
@ Override
Public void onLost Network (Network) {
Super. OnLost (network);
The e (TAG, "onLost==& gt;" + network. The toString ());

}

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

CodePudding user response:

Kill my app, wifi will automatically disconnect

CodePudding user response:

No man or woman??????

CodePudding user response:

Android 10 sandbox mode,,,

CodePudding user response:

I want a solution or effective way of thinking, each big BBS Stack Overflow, lot went, didn't find in Stack Overflow was asked the same question, but no one answer,,,,,,, I Fried mentality and the card for two weeks, too food,,,,
  • Related