Lets say you have a widget that displays the number of minutes remaining until Sunrise. The widget itself cannot, in its own context, determine its location for astronomical calculations since that takes too long. So we use a service to do the actual work of figuring out where we are and what time is Sunrise. The widget sets up an alarm so that its broadcast receiver gets a notification every 60 seconds (or configurable time period) so as to start the service and update the widget.
If I understand Mark's books and other sources correctly this should be the correct way to approach the problem - I hope! So how do I now handle the location issue? getLastKnownLocation() won't work, as pointed out, since there may not be one. So do I have the service set up a location listener to et the initial update and then only take new updates when the location changes by X miles? Or is the service not the correct place to have the listener? At every service start the service needs to know where it is so that it can update the time to sunrise in case we moved. So maybe what I really need is a one-shot quick location fix for the current location and not a listener. I don't care to know where I am unless I am ready to update the widget. Does any of this make sense? Thanks. ...Jake >>>>> "MM" == Mark Murphy <[email protected]> writes: MM> On Fri, Feb 18, 2011 at 11:36 AM, Jake Colman <[email protected]> wrote: >> I am about to reread Mark's chapter on Location Provider from his Busy >> Coders book. If I put my listener only asks for Network updates (coarse >> location) it will still hear GPS updates too if available? MM> Not automatically via the LocationListener, AFAIK. Besides, in your MM> scenario, you don't have permission for GPS. >> And in the >> unlikely event that it has GPS but no network, will I still get a >> location? MM> That depends on which one you register the LocationListener for. If MM> you ask for network, and network is not available, you will not get MM> GPS fixes, AFAIK. MM> -- MM> Mark Murphy (a Commons Guy) MM> http://commonsware.com | http://github.com/commonsguy MM> http://commonsware.com/blog | http://twitter.com/commonsguy MM> Android 2.3 Programming Books: http://commonsware.com/books MM> -- MM> You received this message because you are subscribed to the Google MM> Groups "Android Developers" group. MM> To post to this group, send email to [email protected] MM> To unsubscribe from this group, send email to MM> [email protected] MM> For more options, visit this group at MM> http://groups.google.com/group/android-developers?hl=en -- 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

