Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android WiFi Direct WIFI_P2P_PEERS_CHANGED_ACTION never received

I'm trying to make a multiplayer game for Android via WiFi direct. I followed the instructions on http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html in order to connect to devices.

The ActionListener i use with discoverPeers() returns successfully, but then i never receive the WIFI_P2P_PEERS_CHANGED_ACTION intent upon which i would call requestPeers(). Strangely when i go into WiFi direct system settings on one device, the other is able to successfully detect it through my app. Do i need to make my device discoverable in my app or something? I haven't found anything to indicate that in the Android developer resources regarding WiFi P2P. There is WiFi direct for service discovery, but that's something else entirely, isn't it?

like image 545
cargath Avatar asked Nov 12 '14 08:11

cargath


People also ask

What is P2P in WIFI?

Wi-Fi Direct (also known as peer-to-peer or P2P) allows your application to quickly find and interact with nearby devices, at a range beyond the capabilities of Bluetooth. The Wi-Fi Direct (P2P) APIs allow applications to connect to nearby devices without needing to connect to a network or hotspot.

Is Wi-Fi Direct available for Android?

Wi-Fi Direct is a peer-to-peer Wi-Fi connection between devices that enables faster data transfer than Bluetooth with lower latency than Wi-Fi through a router. You can use it on Android with the Cast Screen feature on certain devices and the Nearby Share file-sharing feature.


1 Answers

You need to run discoverPeers() on other devices as well.
Now you will receive the WIFI_P2P_PEERS_CHANGED_ACTION intent

like image 100
Gaurav Gupta Avatar answered Nov 15 '22 18:11

Gaurav Gupta