It sounds to me like you may have run up against the same problem I
noticed when building and running the WindAndWaves app from "Android
in Action": LocationManager.requestLocationUpdates does a logical AND
operation on the two conditions, minimum distance and minimum time.

This sounds pretty useless at first, but counter intuitive though it
is to AND hem, it does provide more flexibility: you can always get
the effect of an OR by registering the same listener twice, once for
minimum distance changed, and again for minimum time changed.

This is what I did when I rewrote that section fo the original app to
read:

        // we use separate locationListeners for different purposes
        // one to update buoy data only if we move a long distance
(185000 meters, just under the
        // 100 nautical miles we are parsing the data for)
        // another to recenter the map, even when we move a short
distance (50 meters). Now
        // also every minute (60,000mS is one minute), now two seperate
requests.
        if (this.locationProvider != null) {
 
this.locationManager.requestLocationUpdates(this.locationProvider.getName(),
60000, 185000,
                                this.locationListenerGetBuoyData);
 
this.locationManager.requestLocationUpdates(this.locationProvider.getName(),
60000, 0,
                                this.locationListenerRecenterMap);
 
this.locationManager.requestLocationUpdates(this.locationProvider.getName(),
0, 50,
                                this.locationListenerRecenterMap);
        } else {
                Log.e(Constants.LOGTAG, " " + MapViewActivity.CLASSTAG + "  NO
LOCATION PROVIDER AVAILABLE");
                Toast.makeText(this,
                                "Wind and Waves cannot continue, the GPS 
location provider is
not available at this time.",
                                Toast.LENGTH_SHORT).show();
                finish();
        }

If the snippet is too obscure, you can download the Chapter 11 source
code to see the whole thing. You don't have to buy the book to do the
download. But it is worth getting the book despite the redundant use
of 'this' you can see in the snippet above;)

Then again, you did say "10 seconds". But that is an awfully short
period of time.

On Jun 16, 6:18 pm, Baodong Chen <chenbdche...@gmail.com> wrote:
> Hi:
>  I have a APP using Location Service, and i tested it and found that
>  my Location Listener's onLocationChanged() was not called for more
> than ten seconds.
>  but onGpsStatusChanged() was called normally.
>  this means that i can not decide user's location for too long time.
>  I want to know why this happens?
>  is this a normal case or a bug cause this?
>
>  ps: I have posted this to android-ndk, and they suggested me posting here.
>
>  best regards, thanks!

-- 
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