tags:

views:

405

answers:

2

Hi,

I'm trying to figure out a refresh rate to use for my GPS location listener to get around a bug on the HTC Hero where the GPS icon won't remove itself off the notification bar.

http://groups.google.com/group/android-developers/browse%5Fthread/thread/e687b3bfa9146f31/7fa59b0108bbdf89?lnk=gst&q=gps#7fa59b0108bbdf89

Does anyone here have any suggestions? For my app, I'd normally run with a refresh rate of 5 minutes. But when I close the app, and de-register my listeners, the GPS icon sometimes still stays on the notification bar. Does anyone have an HTC Hero and can confirm this?

The link above suggests that using a refresh rate of under 35 seconds fixes the problem, but not sure if that's true.

Thanks

A: 

Have you tried setting your refresh rate lower just to test this theory out, or do you not have a Hero yourself to test on? If it does allegedly fix the problem then just set the refresh rate to a lower setting before you de-register your listeners.

WarrenB
I dont think he has device. However judging by that link it does seem like it should work. If anything I can test it out for you in a couple of days, my friends got a hero
Faisal Abid
@Faisal: If that were the case, the Android SDK still comes with device emulators. If it's a Cupcake/Donut related problem then it should be easy enough to test but it's not apparent from the link whether it's a hardware problem or a firmware problem.
WarrenB
Hi all, yeah I don't have a device which is the main problem, but users are reporting that the icon stays on the notification bar. If someone could try it out that would be awesome. I think the main problem is each manufacturer can modify the android OS as they like - so while the Hero is running 1.6, HTC or Sprint has modified it to have this bug in there. Thanks
Mark
Also, I'm looking at the source code of other projects which use location listeners - and they set their listeners to use a 1 second refresh interval - isn't that extremely short? That would alleviate this problem, but I wouldn't want to burn the user's battery out...
Mark
@Mark: That's why I suggested lowering the refresh rate before closing the program as part of your cleanup code.
WarrenB
@WarrenB - ok sorry I misunderstood - but there's no "closing" of our app right - and I can't run the GPS listener after onPause() is called anyway (otherwise the GPS icon will remain present for sure). Let me know if I'm misunderstanding though, thanks.
Mark
But you have the GPS deactivation code in the onPause() function, right? Just deactivate it, reactivate it with the shorter refresh time which should override the old activation, then deactivate that one. If the shorter refresh really does fix it, then that's problem solved. It's extra overhead, but it's a hack to get around a known bug.I only have a HTC Magic to test on, but reading over the thread you linked seems to imply that overriding the glitched activation with a non glitched one should fix it.
WarrenB
Ok so I just got my hands on a Hero, it definitely has to do with the refresh rate. Using anything above 35 seconds makes the icon sometimes stay on the notification bar, a value less than 35 always gets removed. Ugh. I think leaving the refresh rate at 1 second is fine anyway, I don't see it giving me any location changed notifications after a lock using that interval. Thanks.
Mark
+1  A: 

Try to removeupdates of your location manager in the onDestroy method of your activity tp remove the gps icon.

Just like this..

@Override
public void onDestroy() {
 super.onDestroy();
 locationManager.removeUpdates(this);
}

where locationManager is of type LocationManager.

M.A. Cape