Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android WifiP2p - Get notified when a discovered device goes unavailable

I'm developing a Wifi-direct app in which i'm listing the devices that are available and when the device goes to "unavailble" status i have to remove it from the list.

I tried with the WifiDirectDemo sample, it successfully adds discovered devices in the list but when the device goes unavailable it is not getting notified. "WIFI_P2P_PEERS_CHANGED_ACTION" intent is not fired when device goes unavailable.

When i try "discoverPeers" again, "onPeersAvailable" method gets the device list that are already discovered. It is not removing the unavailble devices.

Is there any way to get notified when the device goes unavailable?

like image 430
user2007256 Avatar asked Apr 11 '13 10:04

user2007256


People also ask

What is P2P in Android?

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.

What is WIFI P2P service?

However, using Wi-Fi Direct (P2P) Service Discovery allows you to discover the services of nearby devices directly, without being connected to a network. You can also advertise the services running on your device. These capabilities help you communicate between apps, even when no local network or hotspot is available.

What is Lg P2P?

Wi-Fi Peer-to-Peer (P2P) allows Android 4.0 or later devices with the appropriate hardware to connect to each other via Wi-Fi without an access point. Android Wi-Fi P2P framework complies with the Wi-Fi Direct standard.


1 Answers

Have a look at this post

in sum: peers who go out of the range will be automatically delete in the peers list after some time - this could belong until 1 minute. I test it with an s4 and s5 mini device. s5 mini discovered the s4 device - when i turned off wifi on the s4 device it took about 20 seconds, then the s5 mini device broadcastes a PEERS_CHANGED Action an the s4 didn't appera any longer in the devicelist...

like image 179
Malungo Avatar answered Sep 23 '22 06:09

Malungo