Location Support on Android is a little unreliable.

91 views
Skip to first unread message

nickk...@gmail.com

unread,
Nov 18, 2013, 12:12:04 AM11/18/13
to codenameone...@googlegroups.com
I've been struggling with this for a while but I think I have some useful information / questions on this that might help get to the bottom of it.

I realise that getCurrentLocation on Android has never worked 'first time' and that its best to set a listener and wait for the current location.  The problem is on some phones it can literally take 10 minutes to get a GPS location - or never if there is no clear view of the sky - and the last known location or the one being reported by getCurrentLocation in the meantime is last time GPS was available and can be very much out of date.  When you check Google Maps it gets your position first time, but switch back to a CN1 app and you are in your old location until GPS is up and running.

My home office is in the basement and gets no GPS signals.  I've just discovered while testing that turning off GPS and leaving on Network Location gets my position immediately - the same as Google Maps always has.

Digging around in the Android Implementation code I see that it pretty much forces GPS location and, if its switched on, waits until GPS location is available and doesn't allow the network location to be used even though its available quick and more accurate than the last known GPS location.

Have I missed something or would it be good to take one of the following actions:
1.  Allow the developer to choose location accuracy so we can switch from network to GPS in code (in which case I would use network to get the general location as it seems to be fast and reliable and then use GPS to fine tune it as I need <100m accuracy 'eventually' while the app is running).

2.  Do this in the Android implementation specifically, use network to getCurrentLocation and use the LocationListener to wait for the GPS to warm up and start providing values.  As getCurrentLocation on Android isn't recommended this might be a solution that makes it useable while still providing more accurate GPS based location when the system eventually warms up.

Basically by forcing the most accurate location provider CN1 is making it difficult to get a quick reasonably accurate location even though it is available on the device through the network location.  This only seems to affect Android - I assume on iOS it is using the network location to get started.

Thanks!

Shai Almog

unread,
Nov 18, 2013, 1:41:06 AM11/18/13
to codenameone...@googlegroups.com, nickk...@gmail.com
Chen can probably give an answer for this, but I can tell you that we are looking at migrating to the new Android location API which should be more powerful and seamless.

Brian Karoney

unread,
Dec 3, 2013, 1:29:09 AM12/3/13
to codenameone...@googlegroups.com, nickk...@gmail.com
Hi,
Did you get a resolution for this issue? Would be really helpful, thanks.

Shai Almog

unread,
Dec 3, 2013, 1:41:09 PM12/3/13
to codenameone...@googlegroups.com, nickk...@gmail.com
Chen improved these in the current version.

Chen Fishbein

unread,
Dec 3, 2013, 4:47:04 PM12/3/13
to codenameone...@googlegroups.com, nickk...@gmail.com
Hi,
In the latest version getCurrentLocation() will return fast on android and will bring network location first .


Reply all
Reply to author
Forward
0 new messages