Hi everyone,
I run into an issue regarding how to use the gps.
My application uses several activities to navigation to some
information. (RootActivity -> MenuActivity -> MenuDetailActivity ->
ItemDetailActivity...)
I use a class extending Application in order to access from all
Activities several data. This class is also the place where I start
the GPS and manage locations update.
I use this code :
[code]
public void registerActivity(){
this.followingActivityCounter++;
Log.i("App", "FollowingActivityCounter:
"+this.followingActivityCounter);
gpsDesactivator.removeCallbacks(desactivateGPSTask);
if(!this.requestUpdates){
Log.i("App", "Request location updates");
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
1000 * 60 * 5, 100, mLocationListener);
}
}
public void unRegisterActivity(){
this.followingActivityCounter--;
Log.i("App", "FollowingActivityCounter:
"+this.followingActivityCounter);
if(this.followingActivityCounter == 0){
Log.i("Counter", "GPS may require do be desactivated,
followingCounter is at "+followingActivityCounter);
gpsDesactivator.removeCallbacks(desactivateGPSTask);
gpsDesactivator.postDelayed(desactivateGPSTask, 5000);
}
}
private Handler gpsDesactivator = new Handler();
private Runnable desactivateGPSTask = new Runnable() {
public void run() {
if(followingActivityCounter == 0){
Log.i("Counter", "GPS OFF, followingCounter is
at
"+followingActivityCounter);
mLocationManager.removeUpdates(mLocationListener);
requestUpdates = false;
}
}
};
[/code]
The idea is that every activity has to register itself in order to
maintain the GPS online only if an activity is in the foreground.
BUT, it seems that the GPS shuts down by itself and start again later.
It leads into several issues when I require the GPS at a specific time
and it is either shut down or not available.
Those lines appears in the logs :
[code]
D/GpsLocationProvider( 1281): exceeded MIN_FIX_COUNT
D/GpsLocationProvider( 1281): stopNavigating
[/code]
Is anyone able to tell me what I do wrong ?
Thanks a lot.
Jb
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en