0

Hi i am working on a real time location tracking application where i have used Fused Location provider Api. I was able to get the location updates when the device is moving. But i was also able to get the location updates even if the device is stationary on a table when i am indoor. So I have calculated the distance between the last location and the current location triggered in Onlocationchanged event and checked whether the distance is less than 30 metres, to know the device is actually moving. But sometimes the distance i get is greater than 400 metres (indoor/Device is Stationary). How Can i ignore the onlocationchange event when i am indoor? Any suggestions are appreciated.Thanks in advance.

hemanth kumar
  • 3,068
  • 10
  • 41
  • 64
  • set a maximum distance cutoff also. If the device moved beyond that within short period, ignore it. – Jeno Karthic Jan 07 '15 at 11:59
  • "smallestdisplacement" is it what you are talking about. jeno? If so i have set its value but i dont think it does much with location updates . – hemanth kumar Jan 07 '15 at 12:05

1 Answers1

1

Unfortunately I don't believe there's much you can do about it.

The reason you see those updates with great changes it's because indoors, you won't get a GPS lock, so the device is relying on cell tower and WiFi hotspot triangulation to determine your location, and something around 200m to 1km is the best you'll get with this kind of technology.

A possible attempt to hack-around it would be to:

  • check the source and precision of the location update
  • use the activity recognition API to guess if the device really moved

but both are a hack, around the technology limitation and might not be as reliable.

Budius
  • 39,391
  • 16
  • 102
  • 144
  • @RishabhSrivastava on the answer there's a link to the tutorial, but apparently google moved the link. You'll have to Google around on other tutorials how to use the Activity Recognition API from Google Play Services – Budius Apr 28 '15 at 13:33
  • what about sensor accelemoter? activity recognition API - is really slow, big delays between walking and still, 10-50 seconds are being updated... such a bad API – user924 Feb 25 '21 at 19:18