07-24-2008 02:08 AM
Hi guys,
when using location provider I've been doing the following:
_locationProvider.setLocationListener(new LocationListenerImpl(), 300, 15, 10);
My question is to do with the passed variables:
int interval, int timeout, int maxAge
Interval is set at 300 seconds, does this mean the Location provider 'wakes up' after five minutes and gets a single position report, or is it constantly updating?
Timeout, this is the time in seconds the GPS chip has to get a report after five minutes? Max age, this should be OLDER than timeout? because if timeout is 15 (meaning the GPS chip COULD get a report in the first 4 seconds) and the maxAge is 10 (anything older than 10 seconds is discarded) a location recieved in the first 4 seconds would be ignored?
Solved! Go to Solution.
07-24-2008 03:21 PM
Here is how it is explained in the JavaDocs. Let us know if you have any further questions about this.
The listener will be called with updated location at the defined interval. The listener also gets updates when the availablilty state of the LocationProvider changes. Updates can be made faster than the interval. If the specified update interval is smaller than the time it takes to obtain the first result, the listener shall receive location updates with invalid Locations at the defined interval until the first location result is available.
The timeout parameter determines a timeout that is used if it's not possible to obtain a new location result when the update is scheduled to be provided. This timeout value indicates how many seconds the update is allowed to be provided late compared to the defined interval. If it's not possible to get a new location result (interval + timeout) seconds after the previous update, the update will be made and an invalid Location instance is returned. This is also done if the reason for the inability to obtain a new location result is due to the provider being temporarily unavailable or out of service. For example, if the interval is 60 seconds and the timeout is 10 seconds, the update must be delivered at most 70 seconds after the previous update and if no new location result is available by that time the update will be made with an invalid Location instance.
The maxAge parameter defines how old the location result is allowed to be provided when the update is made. This allows the implementation to reuse location results if it has a recent location result when the update is due to be delivered. This parameter can only be used to indicate a larger value than the normal time of obtaining a location result by a location method. The normal time of obtaining the location result means the time it takes normally to obtain the result when a request is made. If the application specifies a time value that is less than what can be realized with the used location method, the implementation shall provide as recent location results as are possible with the used location method. For example, if the interval is 60 seconds, the maxAge is 20 seconds and normal time to obtain the result is 10 seconds, the implementation would normally start obtaining the result 50 seconds after the previous update. If there is a location result otherwise available that is more recent than 40 seconds after the previous update, then the maxAge setting to 20 seconds allows to return this result and not start obtaining a new one.
07-27-2008 07:27 PM
MSohm wrote:Here is how it is explained in the JavaDocs. Let us know if you have any further questions about this.
I've read the javadoc, this doesn't help.
07-28-2008 06:50 PM
To anwer my own question:
With this it is possible to define the following
parameters: the interval (in seconds) at which the application wants to receive events; the timeout
value, which indicates how late (in seconds) an update is allowed to be in comparison to the defined
interval; the maxage value, which defines how old the location update value is allowed to be.