Behaviour reproducible in the KitchenSink geolocation.js example on Titanium 1.5 to 1.6+.
Sometimes the listener fails to return any location even after a few minutes. However, if I open a Ti.Map.MapView with the userLocation attribute set to true, my current location is pointed out on the map within 20 seconds. Other location-based apps installed on the Android phone also manage to successfully geolocate me.
Key points from our conversation with Kevin Whinnery about this issue:
- Accuracy level has been set to Ti.Geolocation.ACCURACY_BEST. Our code is more or less the same as the KS example code.
- Reports of geolocation failure from a wide range of devices. We have seen nearly 60% of users dropping out because the app didn't geolocate them. Even our existing users keep asking us to improve geolocation - esp. because they see that the map within our app shows the current location, but our geolocation code fails to work.
- The important thing is that this doesn't happen all the time. Single-shot GPS readings do come back at a reasonable rate when the geolocation is working. But when it isn't working, we have to wait for minutes together with no guarantee of success.
- Opening & locating ourselves in Gowalla or other location-based apps ensures that the Kitchen Sink demo always works the next time we open it.
We don't run the geolocation call within the app.js context. We open a heavyweight window using a URL from app.js. From this heavyweight window, we open another window using a URL. It is in this window's context that the geolocation call occurs.