Christofer Klassen Christofer Klassen - 1 year ago 110
Android Question

Android WifiP2pManager discoverServices timeout

I've been working with the Android WifiP2pManager to discover specific services on other devices. I'm wondering if there is a known timeout period for the function

public void discoverServices (WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener)

I can't find any resources on it in the Android API. I'm aware that I can set a listener for a successful discovery, but I don't know how to tell if no discovery has been made.

Additionally, is there any way to stop discovery without entirely stopping the wifi manager's functionality?

Thanks in advance for any help!

Answer Source

As far as I know the clearServiceRequests() should work fine for cancelling service discovery.

In general I have also not found any docs for timeout, thus I have been using 1 minute timeout timer to fix the issue.

Notice though that you should cancel the timeout timer once you have gotten the callback called once, after that you should just wait for new services being discovered.

I have also not seen any docs for how long the service discovery timeout should be between different services, but with some testing I have determined that it should be at least 5 seconds, in order to get services available discovered nicely.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download