Android WifiP2pManager 发现服务超时
Android WifiP2pManager discoverServices timeout
我一直在使用 Android WifiP2pManager 来发现其他设备上的特定服务。我想知道该函数是否有已知的超时期限
public void discoverServices (WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
我在 Android API 中找不到关于它的任何资源。我知道我可以为成功的发现设置一个侦听器,但我不知道如何判断是否没有发现。
此外,有没有什么方法可以在不完全停止 wifi 管理器功能的情况下停止发现?
在此先感谢您的帮助!
据我所知,clearServiceRequests() 应该可以很好地取消服务发现。
总的来说,我也没有找到任何关于超时的文档,因此我一直在使用 1 分钟的超时计时器来解决这个问题。
请注意,一旦回调被调用一次,您应该取消超时计时器,之后您应该等待发现新服务。
我也没有看到任何文档说明不同服务之间的服务发现超时应该有多长,但是通过一些测试我确定它应该至少为 5 秒,以便很好地发现可用的服务。
https://sphen.proxmobil.com/android-wi-fi-direct-service-discovery/
这篇博客提到超时是 120 秒。
Service discovery will only last for 120 seconds from the time the
discoverServices method of WifiP2pManager is called. If application
developers require service discovery for a longer period, they will
need to re-call the WifiP2pManager.discoverServices method.
我一直在使用 Android WifiP2pManager 来发现其他设备上的特定服务。我想知道该函数是否有已知的超时期限
public void discoverServices (WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)
我在 Android API 中找不到关于它的任何资源。我知道我可以为成功的发现设置一个侦听器,但我不知道如何判断是否没有发现。
此外,有没有什么方法可以在不完全停止 wifi 管理器功能的情况下停止发现?
在此先感谢您的帮助!
据我所知,clearServiceRequests() 应该可以很好地取消服务发现。
总的来说,我也没有找到任何关于超时的文档,因此我一直在使用 1 分钟的超时计时器来解决这个问题。
请注意,一旦回调被调用一次,您应该取消超时计时器,之后您应该等待发现新服务。
我也没有看到任何文档说明不同服务之间的服务发现超时应该有多长,但是通过一些测试我确定它应该至少为 5 秒,以便很好地发现可用的服务。
https://sphen.proxmobil.com/android-wi-fi-direct-service-discovery/
这篇博客提到超时是 120 秒。
Service discovery will only last for 120 seconds from the time the discoverServices method of WifiP2pManager is called. If application developers require service discovery for a longer period, they will need to re-call the WifiP2pManager.discoverServices method.