扫描附近的 Wifi P2P 服务

Scan nearby Wifi P2P services

所以,我想制作一个应用程序来启动 Wifi P2P 服务并扫描附近可用的 Wifi P2P 服务。我会这样create Wifi P2P service

但是如何扫描附近的P2P服务呢?有2种方式声称可以扫描this and this。我不明白两者之间的区别。我确实尝试观看 youtube 视频,但他们在重复同样的事情。请告诉我使用哪一个来扫描附近由其他手机创建的 P2P 服务。

这两种方法都会扫描附近的 P2P 设备。 this will show list of peers(devices) nearby whereas this 在您想要检索其他设备在设置 WifiP2pDnsSdServiceInfo 时使用的 "Map" 时很有用。