Search code examples
javaandroidsocketstcpwifi

How does shareit discovers nearby devices android programmatically


I'm want to create a file sharing app like shareit but I'm really confused about how shareit discovers the nearby devices.

When you click receive button shareit creates a hotspot at the receiver side and the sender without connecting to the hotspot shows the receiver name. How is that possible?

If shareit uses Wi-Fi direct then what's the point of creating hotspot?

And to use Network Service Discovery (NSD) both server and client should be on same network so I think shareit is using something else

If anyone can explain this concept of shareit it will be very helpful.


Solution

  • I finally found the answer! SHAREit uses WiFi SSID to identify the nearby app users. The SSID Consist of two partslike this. BAHD-bXViYQ WHERE 'B' Stands for ANDROID DEVICE and the AHD for the user icon. the second part is the user name encoded in Base64. In this example my name muba. I hope this answer helps save some time.