strange behavior locationupdates gps

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

strange behavior locationupdates gps

Postby eppinator » Tue Mar 09, 2010 5:23 pm

Hi.
I played around with the locationframework and have a question about the the gpsprovider.

When registering a locationlistener you can specify minTime and minDistance. I know from the documentation these parameters are more "guidelines" but I thought it should work at least approximately.

When registering a locationlistener for the gpsprovider with setting minTime to let's say 30 seconds (30000ms) and minDistance to 0, meaning I want an update each 30 seconds, regardless how far I have moved something strange happens:
The gps starts. When it has got the first position fix, it sends positionupdates every second for 10 times, then gps stops. 20 seconds later (which as I discovered is the intervaltime 30 seconds after starting the first update) it reactivates and gets a new fix. again its updating 10 times and then stops. And so on...
STRANGE!
Why doesn't it update once every 30 seconds like i specified? Why 10 times with an interval of 1 second and then a break until the next specified updateinterval?
Has somebody seen this too?
I'm using android 1.6 on a G1.
Any ideas?

Apart from that it seems that the networkprovider couldn't provide locationupdates faster than about a minute.

Regards.
eppinator
Junior Developer
Junior Developer
 
Posts: 10
Joined: Thu Feb 11, 2010 1:00 pm

Top

Postby jean_francois » Fri Mar 12, 2010 1:30 am

I have this same problem. I am especially interested because I have onLocationChanged calling a remote script, which I don't intend on calling every second. Would it make sense to write a timer loop to call the script instead of relying on the minTime to do its job?
jean_francois
Freshman
Freshman
 
Posts: 6
Joined: Fri Mar 12, 2010 1:20 am

Postby jean_francois » Thu Mar 18, 2010 4:16 pm

locationManager.requestLocationUpdates(provider, 4000, 10, locationListener);

I have the gps set to update every 4 seconds, and/or ten meters. Why are these strange interval gaps forming in my updates?
Attachments
Location_output640.jpg
LocationUpdate intervals
Location_output640.jpg (160.23 KiB) Viewed 574 times
jean_francois
Freshman
Freshman
 
Posts: 6
Joined: Fri Mar 12, 2010 1:20 am

Postby Cheesy » Thu May 06, 2010 12:39 am

I have the same problem with HTC Desire (Android 2.1). Setting a minTime of 30000ms, I expected updates at approximately 30s intervals.

Instead, what I see is exactly like eppinator:

- First Fix
- 10 location updates at 1s intervals
- 30s gap with no update
- First Fix
- 10 location updates at 1s intervals
- 30s gap with no update
repeat...

Plus I'm getting GPS_EVENT_STOPPED / GPS_EVENT_STARTED message pairs between each 1s reading.

Although not specifically against the specification ("If minTime is greater than 0, the LocationManager could potentially rest for minTime milliseconds between location updates to conserve power."), the 10 updates at 1s intervals looks wrong...
Cheesy
Freshman
Freshman
 
Posts: 2
Joined: Thu May 06, 2010 12:29 am

Postby eppinator » Thu May 06, 2010 12:22 pm

Strange!
Also did another test this morning with minTime 10000ms and minDistance 10m while driving with the bike, resulting in locationgroups seen on the image....

The whole GpsProvider is problematic because that behavior makes it complicated to get constant periodic updates like expected.
I think I'm gonna implement it like in this thread: battery-effects_with_gps_and_a_locationlistener-t11057.html having my own timer and interval and activating/stopping location updates from the gpsprovider manually
Attachments
2010-05-06.PNG
Location updates from GpsProvider with minTime=10000 minDistance=10
2010-05-06.PNG (1.35 MiB) Viewed 537 times
eppinator
Junior Developer
Junior Developer
 
Posts: 10
Joined: Thu Feb 11, 2010 1:00 pm

Postby Cheesy » Thu May 06, 2010 1:06 pm

I had a look at the source (GpsLocationProvider.java) and it's been done deliberately:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. // number of fixes to receive before disabling GPS
  2. private static final int MIN_FIX_COUNT = 10;
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Therefore, it will normally provide (MIN_FIX_COUNT+1) location updates before turning off the GPS for minTime (assuming minDistance = 0, otherwise minDistance may cause some of the location updates to be skipped).

Not an efficient use of the battery when all you want is 1 update every minTime seconds, rather than 11!

I think I'm gonna implement it like in this thread: battery-effects_with_gps_and_a_locationlistener-t11057.html having my own timer and interval and activating/stopping location updates from the gpsprovider manually

Agreed - that does seem the only way to get updates at a regular frequency (and hopefully save some battery life).
Cheesy
Freshman
Freshman
 
Posts: 2
Joined: Thu May 06, 2010 12:29 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 1 guest