'Xamarin.Android I have installed API version 28 but the project is not building
How to fix it?
In general, my task is to write a function that connects to a Wifi point. It returns True if the password is correct and False otherwise. I had Api version 31 by default, but my code did not work and I decided to put 28, since I have Android 9 on my phone.
private async Task<bool> ConnectWifi(string ssid, string pass)
{
try
{
wifi.SetWifiEnabled(true);
var formssid = $"\"{ssid} \"";
var formpass = $"\"{pass} \"";
var config = new WifiConfiguration
{
Ssid = formssid,
PreSharedKey = formpass,
Priority = 0
};
var result = wifi.AddNetworkPrivileged(config);
if (result.NetworkId == -1)
return false;
wifi.EnableNetwork(result.NetworkId, true);
return true;
}
catch { }
return false;
}
Solution 1:[1]
The best practice is to target the latest android version and set the minimum target version to Android 9 or below, so you can use it on your phone. Anything else doesn't really make sense :/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jjj |

