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
 
#11

AW: Android - delete WIFI

  Alt 26. Jan 2018, 20:35
It does not work, it only shuts down and does not delete saved connection settings.

Delphi-Quellcode:
procedure TfrmApp.RemoveWifiList;
var
  WifiManagerObj: JObject;
  WifiManager: JWifiManager;
  List: JList;
  i: Integer;
  LWifiConf: JWifiConfiguration;
  LSsid: String;
  LNetId: Integer;
begin
  try
  WifiManagerObj := SharedActivityContext.getSystemService(TJContext.JavaClass.WIFI_SERVICE);
  WifiManager := TJWifiManager.Wrap((WifiManagerObj as ILocalObject).GetObjectID);

  List := WifiManager.getConfiguredNetworks;

  for i := 0 to List.size -1 do
  begin

    LWifiConf := TJWifiConfiguration.Wrap( List.get(i) );
    LSsid := JStringToString( LWifiConf.SSID );
    LNetId := LWifiConf.networkId;

    WifiManager.removeNetwork( LNetId );

    WifiManager.disableNetwork(LNetId);

    WifiManager.disconnect;
    WifiManager.saveConfiguration();

  end;

  except
    on E: exception do
    begin
      ShowMessage('Remove: '+E.Message);
    end;
  end;

end;
Daniel

Geändert von danten (26. Jan 2018 um 20:59 Uhr)
  Mit Zitat antworten Zitat