Search code examples
androidandroid-wifiandroid-location

getSpeed() of Location is not working on WiFi


I want to calculate the speed of user on WiFi. I am getting location updates via. onLocationChanged() but every time hasSpeed() returning false and getSpeed() returning 0.0.

Is there any API available to get speed on WiFi or I need to calculate speed manually? Any help or guidance will be well appreciated.

Note: I am able to get the speed on GPS.


Solution

  • You won't be able to use getSpeed() when the user is only connected to WiFi. WiFi location works based on known locations of networks the phone sees. Unlike GPS, this will only ever provide a rough location, so there's no way to calculate speed.

    Think about it like this: If I start at point A and walk 10 feet to point B, will there be any chance in the WiFi networks I can see? Probably not. Will be there be a change in my GPS coordinates? With a decent view of the sky, yes.