gpt4 book ai didi

android - 如何在 Android 中以编程方式禁用特定 SSID 的 WiFi 自动重新连接?

转载 作者:行者123 更新时间:2023-12-02 13:53:04 26 4
gpt4 key购买 nike

如何以编程方式禁用特定 SSID 的 WiFi 自动重新连接?我们可以按照屏幕截图中的说明手动完成此操作。我想知道我们如何在应用程序内做到这一点。 enter image description here

最佳答案

您可以尝试查看 WifiManager 的 android api 文档 here .

a) See WifiNetworkSpecifier.Builder#build() for new mechanism to trigger connection to a Wi-Fi network. b) See addNetworkSuggestions(java.util.List), removeNetworkSuggestions(java.util.List) for new API to add Wi-Fi networks for consideration when auto-connecting to wifi. Compatibility Note: For applications targeting Build.VERSION_CODES.Q or above, this API will always return -1.

如果你再看看 removeNetworkSuggestions(java.util.List) Android-API

Remove some or all of the network suggestions that were previously provided by the app. See WifiNetworkSuggestion for a detailed explanation of the parameters. See WifiNetworkSuggestion#equals(Object) for the equivalence evaluation used.Requires Manifest.permission.CHANGE_WIFI_STATE

因此,如果您在应用中提供了网络建议,您也可以再次删除此建议。这样,它就不会再自动重新连接。

编辑:另请考虑这一点:

If the user uses the Wi-Fi picker to explicitly disconnect from one ofthe network suggestions when connected to it, then that network isignored when it is still in range. During this period, that networkwill not be considered for auto-connection, even if the app removesand re-adds the network suggestion corresponding to the network.

关于android - 如何在 Android 中以编程方式禁用特定 SSID 的 WiFi 自动重新连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56143622/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com