legendaryfox/bamft — Issue #8: Intermittent crashes on ScheduleListActivity
Author: legendaryfox
Created: 2012-02-11 05:42:47+00:00
State: open

I'm still getting some crashes when trying to load ScheduleListActivity; it doesn't happen all the time, but it does still happen.

After tracing through debugger, I found the problem was that this line: `Location userLocation = locationManager.getLastKnownLocation(bestLocationProvider);` kept coming back null, and when it did, it would crash (when it didn't come back null it would be okay).

I did some research, and it seems that it the function getLastKnownLocation is **not blocking**; in other words, even if it can't get a fix (getLastKnownLocation takes from cache) and even if location providers are enabled, it will just return the location.

I tried looking to see if people had any options to deal with this, but nothing came up. So I'm thinking we might have a few options...

a) if it comes up null, we could have the location default to the center of boston?
b) we could somehow force getLastKnownLocation to be blocking - that is, we could force it to get a lock on before moving forward. I'm not entirely sure how to do this.

I'm still trying to see if there are alternatives and what other apps use - surely other people must've found a way to do this. Interestingly enough, getLastKnownLocation is supposed to grab cache'd data, so we shouldn't be having this problem. It could be something entirely different.