Turning on wifi using WifiManager stops to work on Android 10

public boolean setWifiEnabled (boolean enabled) This method was deprecated in API level 29. Starting with Build.VERSION_CODES#Q, applications are not allowed to enable/disable Wi-Fi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always return false and will have no effect. If apps are targeting an older SDK ( Build.VERSION_CODES.P or below), they can … Read more

How to get available wifi networks and display them in a list in android

You need to create a BroadcastReceiver to listen for Wifi scan results: private final BroadcastReceiver mWifiScanReceiver = new BroadcastReceiver() { @Override public void onReceive(Context c, Intent intent) { if (intent.getAction().equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) { List<ScanResult> mScanResults = mWifiManager.getScanResults(); // add your logic here } } } In onCreate() you would assign mWifiManager and initiate a scan: mWifiManager = … Read more

How do I see if Wi-Fi is connected on Android?

You should be able to use the ConnectivityManager to get the state of the Wi-Fi adapter. From there you can check if it is connected or even available. ConnectivityManager connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (mWifi.isConnected()) { // Do whatever } NOTE: It should be noted (for us n00bies here) that you … Read more

How do I connect to a specific Wi-Fi network in Android programmatically?

You need to create WifiConfiguration instance like this: String networkSSID = “test”; String networkPass = “pass”; WifiConfiguration conf = new WifiConfiguration(); conf.SSID = “\”” + networkSSID + “\””; // Please note the quotes. String should contain ssid in quotes Then, for WEP network you need to do this: conf.wepKeys[0] = “\”” + networkPass + “\””; … Read more