2

I know that Location.getTime() returns something not compatible with system time. So how can I judge if the lastKnowLocation is too old so I won't use it before an update is made?

Thanks in advance

user1934733
  • 171
  • 1
  • 1
  • 6

3 Answers3

1

Location.getTime() returns time in milliseconds since epoch (January 1, 1970.). Convert it to Date and you will have the time the location was saved.

Chris K.
  • 977
  • 8
  • 18
0

Use getElapsedRealtimeNanos () and minus the value away from elapsedRealtimeNanos () in System class to get age of location update

wakaka
  • 533
  • 1
  • 7
  • 21
0

Well how long before a location is stale is up to you. The design pattern laid out here says use what ever location you have until you get a better one. Think about my last known location. I'm sitting at a laptop for the last six hours writing code and sharing on stackoverflow.

location processing time flow

  1. Request a better location
  2. Do whatever you want or need to do with the location you have.
  3. When the better location comes in repeat step 2.
Community
  • 1
  • 1
danny117
  • 5,581
  • 1
  • 26
  • 35