>>>>> "Jake" == Jake Colman <[email protected]> writes:
Jake> Yes, I know that there are a million resources out there that Jake> deal with the best way to obtain a location and I did google Jake> quite a bit before making this post. If someone can point me Jake> to something I missed, I'd appreciate it. Jake> Having said this my needs (for the purpose of this question) Jake> are quite simple: Once an hour I want to obtain my location Jake> from the Network. Jake> Here is what I did: Jake> 1) Created an alarm to trigger once an hour. Jake> 2) Invoke LocationManager.removeUpdates(). Jake> 3) Request location updates, specifying a listener. I am Jake> specifying minTime and minDistance values of 0. Jake> 4) As soon as the listener is fired, save the location and Jake> invoke LocationManager.removeUpdates(). Jake> I see a few issues with this: Jake> 1) I am shutting down the listener as soon as I get an update. Jake> But I should probably wait for a few updates in order to Jake> allow it to zero in on the location (I already have code Jake> that figures out best location from those available). Jake> 2) The listener does not seem to fire consistently. My Jake> location is not always getting updated and it looks like the Jake> listener is simply not getting called. Jake> I ran some tests where I never remove updates. With the above Jake> settings my listener is being called appx every 45 seconds. So Jake> I know that my overall code is written correctly. Jake> What is the canonical "best" way to do what I want? Should I Jake> collect updates in my Listener for, say, 2 minutes and use an Jake> alarm (set to trigger two minutes after my hourly alarm is Jake> triggered) to remove updates? Is there a better way to solve Jake> this problem? I think I know why my listener is not always firing but I'm not sure what to do about it. The request for location updates is coming from a Service that is periodically updating a widget. Looking the logcat, it looks like the service gets destroyed before I received the update. If the service is destroyed, the listener object is gone too! How does one typically deal with this situation? -- Jake Colman -- Android Tinkerer -- 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

