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
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
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.
Use getElapsedRealtimeNanos () and minus the value away from elapsedRealtimeNanos () in System class to get age of location update
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.