After re-reading the summaries for the various dev groups, re-posting
this to android-developers because it's probably a better fit...

I'm encountering what appears to be inconsistencies with how the
distance and time filter settings for the LocationManager are
currently working when I attempt to log the current GPS location in
an
application that I'm writing.  The phone that I'm using to log is a
G1
(non-dev phone).
Basically, I'm trying to run a GPS logger as a background service
that
starts when the phone is booted up.  The code that loads the Service
seems to work properly so I'm going to provide a snippet of the
actual
GPS logger itself.
---------------------------------------------------------------------------
--------------------------
public class LocationLoggerService extends Service {
        @Override
        public IBinder onBind(Intent intent) {
                return null;
        }
        @Override
        public void onCreate() {
                // setup logging
                long maxTime = 360000;
                int maxDist = 3;
                startLocationUpdates(maxTime, maxDist);
        }
        public void startLocationUpdates(long maxTime, int maxDist) {
                // start location updates
                LocationManager lm = (LocationManager)getSystemService
(Service.LOCATION_SERVICE);
                LocationListener mLocationListener = new
LocationListener() {
                        @Override
                        public void onLocationChanged(Location loc) {
                                float speed = loc.getSpeed();
                                double longitude = loc.getLongitude
();
                                double latitude = loc.getLatitude();
                                long time = loc.getTime();
                                time = time / 1000;
                                try {
                                        *submit stuff goes here*
                                } catch (Exception e) {
                                        e.printStackTrace();
                                }
                        }
                        @Override
                        public void onProviderDisabled(String arg0) {
                        }
                        @Override
                        public void onProviderEnabled(String arg0) {
                        }
                        @Override
                        public void onStatusChanged(String arg0, int
arg1, Bundle arg2) {
                        }
                };
                Criteria criteria = new Criteria();
                criteria.setAccuracy(Criteria.ACCURACY_FINE);
                lm.requestLocationUpdates(lm.getBestProvider(criteria,
true), maxTime, maxDist, mLocationListener);
        }
}

---------------------------------------------------------------------------
--------------------------
What I'm expecting to happen with this code is that the
LocationManager either 1) logs a fine (no wi-fi location) location
every half hour or 2) logs a fine location every time the device
moves
2m.  This code should only register a point every 30 minutes unless
the device is in motion.
However, I'm finding that it actually does the following:
1) on startup, logs about five points while the device is stationary
and then proceeds to log about every 30 seconds.
2) when the device is in motion, logs sporadically - basically a trip
of around 10-15 kilometers only logged around 72 points, many with
incorrect speed
I think what I'd like is if I could utilize the maxTime and maxDist
settings without the second case occuring (it seems to be constantly
dropping the GPS fix and then trying to re-acquire it, introducing a
lot of error in the process).
Any suggestions on how to solve these issues would be greatly
appreciated.
Thanks!
-b

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to