Stack Overflow Asked by Ahmad Idrees on December 5, 2021
Wifi configuration is deprecated at 29 Android Version. I want to share the file using WIFI but there is no such library which i can use for this purpose. So If Anybody has a solution for this problem kindly share it.
WifiConfiguration wc = new WifiConfiguration();
wc.SSID = ""SSID_NAME""; //IMP! This should be in Quotes!!
wc.hiddenSSID = true;
boolean res1 = wifiManag.setWifiEnabled(true);
int res = wifi.addNetwork(wc);
Log.d("WifiPreference", "add Network returned " + res );
boolean es = wifi.saveConfiguration();
Log.d("WifiPreference", "saveConfiguration returned " + es );
boolean b = wifi.enableNetwork(res, true);
Is there any alternative for WifiConfiguration which i can use it!
WifiConfiguration was deprecated in API level 29. Now, WifiNetworkSpecifier.Builder solve my problem.
WifiNetworkSpecifier wifiNetworkSpecifier = new WifiNetworkSpecifier.Builder()
.setSsid(ssid)
.setWpa2Passphrase(password)
.build();
NetworkRequest networkRequest = new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.setNetworkSpecifier(wifiNetworkSpecifier)
.build();
ConnectivityManager connectivityManager = (ConnectivityManager)this.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
connectivityManager.requestNetwork(networkRequest, new ConnectivityManager.NetworkCallback());
Answered by Amanullah Asraf on December 5, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP