Thema: Delphi Android - delete WIFI

Einzelnen Beitrag anzeigen

Rollo62

Registriert seit: 15. Mär 2007
3.926 Beiträge
 
Delphi 12 Athens
 
#10

AW: Android - delete WIFI

  Alt 22. Jan 2018, 17:07
I found some time to check your demo.

Its hard to check, since I had to cleanup a lot.
I do not use UniDac, etc., so I have to separate some functions first,
and I tried to use with my fixed network ID here.

I assume your main goal is to connect with one network from the http list only, right ?

An my Nexus9 tablet I can move through the preconfigured network list, since I can see their SSID's (I removed saveConfiguration, to not destroy all my settings here).
But after removeNetwork it still connects to a removedSSID.

I'M not sure whether this behaviour is normal, but I lost a lot of time to unscramble the code, so I haven't test unter other settings.
The docs say this is depreceated anyway.
So all I can say now that I can walk through the networkID's, calling removeNewwork, but still my tablet keeps connected, and also will reconnect.


Delphi-Quellcode:
procedure TfrmApp.RemoveWifiList;
var
  WifiManagerObj: JObject;
  WifiManager: JWifiManager;
  ScanResult: JScanResult;
  List: JList;

  //WifiConf: JWifiConfiguration;
  i: Integer;
  netID: integer;
  LWifiConf: JWifiConfiguration;
  LSsid: String;
  LNetId: Integer;
begin
  try
  WifiManagerObj := SharedActivityContext.getSystemService(TJContext.JavaClass.WIFI_SERVICE);
  WifiManager := TJWifiManager.Wrap((WifiManagerObj as ILocalObject).GetObjectID);

  Memo1.Lines.Insert(0, 'RemoveWifiList:');

  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;

    Memo1.Lines.Insert(0, '- SSID: ' + LSsid + ' ID(' + LNetId.ToString + ') REMOVED');

    WifiManager.removeNetwork( LNetId );
// WifiManager.saveConfiguration(); // TEST this is maybe missing to store permanently


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

...

end;

Rollo
  Mit Zitat antworten Zitat