I want to retrieve GPS location of one android device and fetch it to another android device in realtime. I have gone through many resources and came to know that it can be implemented using GCM, FCM, sockets or by polling. However GCM or FCM cannot provide the updates in realtime and polling will lead to more battery drainage. For Sockets I have gone through socket.io implementation but I don't know whether it is the perfect implementation. So please provide suggestions on how to better implement that.

Now another scenario is if multiple users are connected to the server through the same socket then how can we figure which user is monitoring whom ?

Please help...

1

There are 1 best solutions below

0
On BEST ANSWER

You can use firebase database. Once you get the firebase sdk integrated in your project, sending and getting location updates between devices will be straightforward.

You can save a location entry (lat, lng, timestamp) to the db in one device and in the other you can listen for child events. If the two devices are reading from and writing to the same db reference (say same array) it will work like charm.

Get started here:

https://firebase.google.com/docs/database/android/start/