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?
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.
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.
You need to run discoverPeers()
on other devices as well.
Now you will receive the WIFI_P2P_PEERS_CHANGED_ACTION
intent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With