Alex, even if you use register / remove in onResume() / onPause(),
you're saying you still see the GPS icon get stuck on the notification
bar, unless you set your interval rate to something less than 35
seconds?:

  @Override
  protected void onPause() {
      super.onPause();
      locationManager.removeUpdates(this);
  }

  @Override
  protected void onResume() {
      super.onResume();
      locationManager.requestLocationUpdates(...);
  }

I made a test app with the above structure, and sometimes the GPS icon
will still get stuck on the notification bar. I'm using an interval of
two minutes. I wonder if I have to set it to < 35 seconds to get this
to stop? What a pain.

Thanks

On Dec 8, 3:28 pm, Alex <acni...@gmail.com> wrote:
> I see that too. There's not much more we can do other than release it
> in onPause or onDestroy.
>
> On Dec 5, 8:42 pm, Mark Wyszomierski <mar...@gmail.com> wrote:
>
>
>
> > Actually on the G1 running 1.5, theGPSicon doesn't remove itself
> > from the notifications bar if the phone goes into sleep mode while you
> > have a listener registered (even though I'm deregistering onPause()).
> > Example:
>
> >  1) on app start, register listener forgps.
> >  2) onPause() to home screen, log shows listener deregistered, icon
> > disappears.
> >  3) bring app to foreground again,gpslistener is registered, icon is
> > showing.
> >  4) let phone fall asleep with your activity in the foreground
> >  5) onPause() is still called, deregistering listener, log shows
> > deregister event.
> >  5) hit the menu key to wake the phone (but not completely awake yet)
> >  7)gpsicon is still in status bar.
>
> > I'm not sure ifgpsis actually running in this state, or it's just
> > stuck on the titlebar. I'm hoping it's just stuck on the titlebar when
> > falling asleep...
>
> > Thanks
>
> > On Dec 5, 12:25 am, Alex <acni...@gmail.com> wrote:
>
> > > This same code works fine on a G1 (1.5/1.6), Magic, Droid, Cliq,
> > > Samsung Behold and Moment.  I was previously using a 10 minute update
> > > interval.
>
> > > I think it was the firmware update Sprint/HTC applied recently.  While
> > > it fixed many of the gigantic bugs with theHero, it introduced this
> > > one.
>
> > > I confirmed it with this test code:
>
> > > public class GPSBugActivity extends Activity implements
> > > LocationListener
> > > {
> > >         private static final int MIN_TIME = 60000; // 1 minute
> > >         private static final int MIN_DISTANCE = 1000; // 1 kilometer
>
> > >         private LocationManager locationManager = null;
>
> > >         @Override
> > >         public void onCreate(Bundle savedInstanceState)
> > >         {
> > >                 super.onCreate(savedInstanceState);
> > >                 setContentView(R.layout.main);
>
> > >                 locationManager = (LocationManager) getSystemService
> > > (Context.LOCATION_SERVICE);
> > >                 
> > > locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
> > > MIN_TIME, MIN_DISTANCE, this);
> > >         }
>
> > >         @Override
> > >         protected void onDestroy()
> > >         {
> > >                 super.onDestroy();
>
> > >                 locationManager.removeUpdates(this);
> > >         }
>
> > >         @Override
> > >         public void onLocationChanged(Location arg0)
> > >         {
> > >         }
>
> > >         @Override
> > >         public void onProviderDisabled(String arg0)
> > >         {
> > >         }
>
> > >         @Override
> > >         public void onProviderEnabled(String arg0)
> > >         {
> > >         }
>
> > >         @Override
> > >         public void onStatusChanged(String arg0, int arg1, Bundle arg2)
> > >         {
> > >         }
>
> > > }
>
> > > The log had the fact that it was removing the listener...but it
> > > doesn't seem to matter...
>
> > > 12-05 00:20:46.008: DEBUG/LocationManager(1941): removeUpdates:
> > > listener = com.gpsbug.gpsbugactiv...@4348f94012-05 00:20:50.201: DEBUG/
> > > LocationManagerService(70): CdmaPollingThread exiting
>
> > > I'm still not sure if it's actually running theGPSor just flashing
> > > the icon, but either way it looks bad to the end user.
>
> > > -Alex
>
> > > On Dec 5, 12:04 am, Mark Wyszomierski <mar...@gmail.com> wrote:
>
> > > > Alex, have you tried a simple test of just registering, then
> > > > deregistering the listeners in an otherwise empty project? On my
> > > > G1/1.5, I don't get this behavior, theGPSicon goes away shortly
> > > > after a deregister. If it's a quirk on that device, that is worrisome.
> > > > In that case, many apps will burn out the user's battery?
>
> > > > Mark
>
> > > > On Dec 4, 11:57 pm, Alex <acni...@gmail.com> wrote:
>
> > > > > I can confirm that an update interval of greater than 35 seconds
> > > > > causes theGPSstatus icon to blink on an Sprint HTCHero(Firmware
> > > > > 1.56.651.2).  It does not ever go away, it will blink all day long.
> > > > > You can run and exit Google Maps and it goes away.
>
> > > > > So now I get to decide whether to have this "bug" or run my location
> > > > > listeners at a much faster rate than I normally would.
>
> > > > > From the docs for requestLocationUpdates:
> > > > > Background services should be careful about setting a sufficiently
> > > > > high minTime so that the device doesn't consume too much power by
> > > > > keeping theGPSor wireless radios on all the time. In particular,
> > > > > values under 60000ms are not recommended.
>
> > > > > -Alex
>
> > > > > On Dec 2, 7:54 pm, Ken H <hunt1...@gmail.com> wrote:
>
> > > > > > 1 minute seems long to me too, 5-10 sec is a good generic interval 
> > > > > > if
> > > > > > you just want it to turn off quicker. Also remember that theGPSneeds
> > > > > > a time *and* distance update interval.
>
> > > > > > But my question is this, have you sat down and watched to see if the
> > > > > > little satellite dish disappears after a minute? My guess is it
> > > > > > should. Also remember your app is usually just suspended when you
> > > > > > first turn it off (so it can be booted up quicker). If android needs
> > > > > > the memory it will kill it.
>
> > > > > > Ken
>
> > > > > > On Dec 2, 11:24 am, Mark Wyszomierski <mar...@gmail.com> wrote:
>
> > > > > > > I've been working with the location providers lately, I haven't 
> > > > > > > seen
> > > > > > > this behavior. When I deregister my listeners, theGPSicon goes 
> > > > > > > away,
> > > > > > > I haven't seen it stick around.
>
> > > > > > > Even one minute intervals forGPSseems like a lot for me - I'm
> > > > > > > guessing users won't be able to move fast enough in one minute to 
> > > > > > > make
> > > > > > > any real difference in location. All depends on the app though.
>
> > > > > > > On Nov 19, 6:33 pm, jtoolsdev <brianjto...@gmail.com> wrote:
>
> > > > > > > > I'm looking to a solution using the MyLocationOverlay library 
> > > > > > > > where
> > > > > > > > one can use runOnFirstFix which can launch the thread (which I 
> > > > > > > > already
> > > > > > > > have) when the current location is found.  Once it is found I 
> > > > > > > > can shut
> > > > > > > > down the location stuff as I only need it at the start of the 
> > > > > > > > program.
>
> > > > > > > > On Nov 19, 3:20 pm, Nathan <nathan.d.mel...@gmail.com> wrote:
>
> > > > > > > > > On Nov 19, 12:09 pm, jtoolsdev <brianjto...@gmail.com> wrote:
>
> > > > > > > > > > The recommendation of
> > > > > > > > > > the SDK is for setting up the location listener is to set 
> > > > > > > > > > time at
> > > > > > > > > > 60000ms or 1 minute.  
>
> > > > > > > > > Really? Does Google Maps follow that guideline?
>
> > > > > > > > > > My tests show if you use that number when
> > > > > > > > > > exiting the app it may not shutdownGPS.  
>
> > > > > > > > > Sounds bad.I hope there is an answer for that.
>
> > > > > > > > > Nathan

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