0

In my Android application, I am using the WifiP2pManager API to discover peers with Wifi Direct. It works, and it discovers them as expected after calling

wifiP2pManager.DiscoverPeers(myChannel, myActionListener);

But sometimes, if I turn off a device after it has already been discovered, it still appears in the WifiP2pDeviceList when I discover peers again. I actually have to turn the wifi off and on from the device (that's discovering peers) so that it doesn't show the device (that's off) anymore. Is there a chache that I can clear instead?

I'm developing this app in Xamarin.Android, but an answer in Java/Kotlin would be fine.

EDIT

Just realized that if I wait for a minute, the turned off device doesn't appear in the list of discovered peers anymore. Still would like to know if there's a way to clear the cache sooner.

Drake
  • 2,679
  • 4
  • 45
  • 88

1 Answers1

1

The device does not go away until "discoverPeers()" is called again by the system, which is currently set (in android framework) to be called after 60 sec.

This is normal behavior, probably nothing much you can do about it.

An answer to explain the behaviour: https://stackoverflow.com/a/25154034/3260008

Leo Zhu
  • 15,726
  • 1
  • 7
  • 23