Thank you Mark! That solved the problem - thanks for the swift and helpful response, as ever.
Do you think it is a bug that getLastKnownLocation tends to choke and fail if called from a background thread - is it something that I should reproduce and report to Google? Or is it something that I shouldn't have been trying to do in the first place? :) best wishes, Anna On Jul 16, 10:51 pm, Mark Murphy <[email protected]> wrote: > Anna PS wrote: > > Sorry, I guess I'm being dim. Should I add some code inside the > > onLocationChanged method itself to check the accuracy? And then just > > check this number when the user clicks on the button? > > > public void onLocationChanged(Location location) { > > accuracy = location.getAccuracy(); > > } > > Possibly. I was more thinking that if the user presses the button, and > an immediate getLastKnownLocation() returns null or an > insufficiently-accurate value, you then start paying attention to the > location you get with onLocationChanged(). > > If getLastKnownLocation() was null, the firstfixyou get should be > treated as if it came from your getLastKnownLocation(), and checked for > accuracy. > > If you are waiting for more accurate values, using onLocationChanged() > will be the fastest way to get them, and it gets rid of your background > thread. > > So, set yourself a flag indicating your current state, check that flag > in onLocationChanged(), and take appropriate action -- probably the same > action you were doing in the background thread, just pulled into > onLocationChanged(). > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://twitter.com/commonsguy > > _Android Programming Tutorials_ Version 1.0 Available! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

