Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Cross-Platform-Entwicklung (https://www.delphipraxis.net/91-cross-platform-entwicklung/)
-   -   Delphi Android - delete WIFI (https://www.delphipraxis.net/194859-android-delete-wifi.html)

danten 26. Jan 2018 19:35

AW: Android - delete WIFI
 
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;

localhost 7. Mär 2019 14:27

AW: Android - delete WIFI
 
i have the same Problem. The Result from "removeNetwork" is False.

Developer.Andoird says: "Applications are not allowed to remove networks created by other applications." so my app can not delete everything?

mjustin 7. Mär 2019 14:43

AW: Android - delete WIFI
 
Zitat:

Zitat von localhost (Beitrag 1427216)
i have the same Problem. The Result from "removeNetwork" is False.

Developer.Andoird says: "Applications are not allowed to remove networks created by other applications." so my app can not delete everything?

Correct, see

- https://stackoverflow.com/questions/...rogramatically
- https://developer.android.com/about/...havior-network

Rollo62 7. Mär 2019 16:47

AW: Android - delete WIFI
 
So if we are not allowed to change the Wifi network,
maybe there is any alternative method, which asks the user to change the network ?

I think an app should be able to tell what "preferred" network it should use,
and Google probably put something like special permission dialog in ?

mjustin 7. Mär 2019 16:52

AW: Android - delete WIFI
 
Zitat:

Zitat von Rollo62 (Beitrag 1427254)
So if we are not allowed to change the Wifi network,
maybe there is any alternative method, which asks the user to change the network ?

I think an app should be able to tell what "preferred" network it should use,
and Google probably put something like special permission dialog in ?

The WiFi settings screen can be invoked from code, so the user may be notified about the preferred network first from your app, and then directed to select it there:

- https://stackoverflow.com/questions/...-using-android

- https://developer.android.com/refere...K_WIFI_NETWORK

Rollo62 7. Mär 2019 16:59

AW: Android - delete WIFI
 
Thanks for the info, would be at least the 2nd best option.
I hoped that I could give a parameter with this intent, but it cannot :(


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:50 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz