Hello,
I need to delete all saved WIFI networks for business purposes and retrieve new ones from the list downloaded from the server.
Here the user would click on the WIFI network in the list and join only to her.
Thank you for your help.
Delphi-Quellcode:
procedure RemoveWifiList;
var
WifiManagerObj: JObject;
WifiManager: JWifiManager;
ScanResult: JScanResult;
i: Integer;
begin
WifiManagerObj := SharedActivityContext.getSystemService(TJContext.JavaClass.WIFI_SERVICE);
WifiManager := TJWifiManager.Wrap((WifiManagerObj as ILocalObject).GetObjectID);
for i := 0 to WifiManager.getScanResults.size do
begin
ScanResult := TJScanResult.Wrap((WifiManager.getScanResults.get(i) as ILocalObject).GetObjectID);
WifiManager.removeNetwork(i);
end;
end;
procedure ConnectToSelectedWIFI;
var
WifiManager: JWifiManager;
aSSID, aPASS: string;
WifiConf: JWifiConfiguration;
begin
WifiManager := ??????
WifiConf := ?????
aSSID := '"'+edSSID.Text+'"';
aPASS := '"'+edPASS.Text+'"';
WifiConf.SSID := StringToJString(aSSID);
WifiConf.preSharedKey := StringToJString(aPASS);
WifiConf.hiddenSSID := False;
WIFIManager.addNetwork(WifiConf);
WIFIManager.enableNetwork(WifiConf.networkId,True);
???? Create connections and connect new ???
end;