Thema: Delphi Android - delete WIFI

Einzelnen Beitrag anzeigen

danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#1

Android - delete WIFI

  Alt 17. Jan 2018, 08:25
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;
Daniel

Geändert von danten (17. Jan 2018 um 09:15 Uhr)
  Mit Zitat antworten Zitat