[android-developers] Does getBestLastKnownLocation block?

2010-12-07 Thread Greg Giacovelli
Hi,
I was wondering if this is a bad thing to do or if it is just a buggy
ROM. The location strategy my application uses is from the UI Thread
register for a location update. We then schedule a cancel request on
the handler of the UI thread within a given timeout to cancel the
location update if nothing was returned in that time. After which we
call on the UI thread LocationManager.getBestLastKnownLocation() for
the provider we were interested in.

This seemed like a sane idea since the async callback wouldn't block
and we could give the user some animation loading indication for our
best attempt. And if we timeout we just use the system's last known
location as a best effort follow up. However on certain phones, the
Epic in particular sometimes this call never returns. This call is
documented as being pretty light weight and since all of the other
interaction with the LocationManager is to be done on the UI thread
(like registering for updates) this just seems to be understood as
needing that as well.

Is there a better pattern than this?

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


Re: [android-developers] Does getBestLastKnownLocation block?

2010-12-07 Thread Mark Murphy
On Tue, Dec 7, 2010 at 1:49 PM, Greg Giacovelli miyamo...@gmail.com wrote:
 After which we
 call on the UI thread LocationManager.getBestLastKnownLocation() for
 the provider we were interested in.

There is no getBestLastKnownLocation() in LocationManager in Android.
I am assuming you are referring to getLastKnownLocation().

 However on certain phones, the
 Epic in particular sometimes this call never returns.

Seriously? That's a Galaxy S phone, which is pretty popular, though it
is not one I have in my stable.

It certainly feels like a compatibility bug. Do you have any info on
criteria for when this will block (e.g., only if no providers are
enabled)?

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

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