gps on android -

Hey -

One of my beta testers has a htc thunderbolt runnin 2.3.5 gingerbread.

The app is location aware, and I have the android permissions to fine and course.

Its not comming back with real values…

So i thought it should try fine, and then course (assisted-gps).
Inside a steel building fine, wouldnt work, but course not responding either.

Any ideas?

Works fine on my Moto-Triump. Other beta testers with other devices havent reported back yet.

Build 714.

Thanks! [import]uid: 9070 topic_id: 22565 reply_id: 322565[/import]

I’ve noticed this too. The problem is that Android won’t always give us GPS data. In Corona, we call your Lua listener as soon as Android notifies our code that it has GPS data… but sometimes it can take several minutes until the device calls our code to provide us GPS data. I think some devices are just very slow in getting a fix on the GPS satellites. Bottom line, I don’t think there is much we can do about it on our end.

The one thing we try to do to make it “nicer” is to fetch location data from WIFI first, so at least your app will have close to immediate feedback initially. If we don’t have access to WIFI, then we attempt to fetch location data from the cellular service. Once we get that initial value, we then wait for GPS data… but as you’ve noted, some devices are really bad about acquiring a fix on satellites. I find that the GPS sensor is much more responsive if you are outside. [import]uid: 32256 topic_id: 22565 reply_id: 89964[/import]

Based on the gps event api - i dont see a way to try wifi first, cellular (assuming this is a-gps), and then switch to real gps.

As noted previously i have both fine and course in my android permissions… Logically Corona should hide this from me. :wink:

I can look for errors with the event.time (no time set), or event.errorcode.

Can you define (or reference) the wifi,cellular,gps switching methodology please?

Thanks! [import]uid: 9070 topic_id: 22565 reply_id: 89979[/import]

so far - good android

motorola triumph - ver 2.2.2

bad android

motorola zoom - with 4.01 ics
htc thunderbolt - ver 2.3.5

here is the code fragment (less the acuual listener)…

I could make the delay longer for slower devices (if we build a list somewhere)

+++++++++++++++++++++++++++++

–Start the program!

msg = display.newText( “Updating GPS fix…”, 0, 200, “Verdana-Bold”, 13 )
msg.x = display.contentWidth/2 – center title
msg:setTextColor( 255,255,255 )

system.setLocationThreshold( 1000 )

Runtime:addEventListener(“location”,locationHandler)
native.setActivityIndicator( true )
local function delayinit(event)
print(“delay init…”)

native.setActivityIndicator( false )
msg:removeSelf()

init()
end

timer.performWithDelay(1000,delayinit)
[import]uid: 9070 topic_id: 22565 reply_id: 89982[/import]

Corona “does” hide the implementation details from you. Internally, Corona hits the WIFI and cellular network for location data first for you. You don’t have to do anything in Lua.

The issue is that Android’s sensors are not giving Corona any data. This will happen if the GPS sensor is unable to get a fix on the GPS satellites. Different devices from different manufacturers will show differences as you have noted. Bottom line, there isn’t much we can do about it. We’re at the mercy of the hardware. Also realize that a GPS works best outdoors… and some GPS sensors are better than others.

If you haven’t already, make sure both permissions are set within your build.settings file…
“android.permission.ACCESS_COARSE_LOCATION”
“android.permission.ACCESS_FINE_LOCATION”

The coarse location permission permits Corona to retrieve location data from WIFI and Cellular network.

The fine location permission permits Corona to retrieve location data from the GPS sensor. [import]uid: 32256 topic_id: 22565 reply_id: 90281[/import]

As I already have “android.permission.ACCESS_COARSE_LOCATION”
“android.permission.ACCESS_FINE_LOCATION” in my build.settings, I guess its time to build a list of slow android gps units (and their chipsets).

While I could extend the timer delay to day 5 seconds+, I dont want to irritate those with faster responding chip sets.

How long does course location finding event really neeed?

Thanks! [import]uid: 9070 topic_id: 22565 reply_id: 90295[/import]

Course locations data is usually received quite quickly provided that the device has access to the Internet or cell towers of course. How long? Sometimes within 5 seconds… sometimes longer on a low-end Android device.

Regarding fine location, sometimes it takes the Android device several minutes to get a fix on a satellite. Terrible, right?

Also, you might want to check if your Android device’s GPS is enabled. You would do so by going to the Home screen, tapping the Setup button, and then selecting “Location and Security” from the list. Make sure that the following options are checked:

  • Use wireless networks
  • Use GPS satellites

If the above are not checked, the Corona will be unable to receive data from the GPS or the network. In fact, Corona will respect these settings as they are changed dynamically/on-the-fly. Some Android devices allow you to change the location settings by dragging the top status bar down. [import]uid: 32256 topic_id: 22565 reply_id: 90312[/import]

Here is more for the list…

I bumped the wait for lock timer to 10sec.

Motorola Triump - OK
Droid Pro - OK
Motorola Xoom - OK
HTC Thunderbolt - only ok after getting a GPS lock before the app (documented problems with Assisted)
HTC Double Shot - OK
Asus Transformer - OK
Samsung Vibrant (runing ICS) - failed No GPS driver [import]uid: 9070 topic_id: 22565 reply_id: 90622[/import]

I am having a really hard time with my Android app getting my current location using the geolocation javascript API. My app just uses showWebPopup to load a mobile web page that gets location and works perfectly in all browsers as well in the iOS app. I believe I have all the android permissions set correctly but it is still not prompting to allow share location like the iOS app does and I believe that is why I am not getting Lat/Lng.
What am I missing?
Thanks. [import]uid: 183369 topic_id: 22565 reply_id: 137247[/import]

I am having a really hard time with my Android app getting my current location using the geolocation javascript API. My app just uses showWebPopup to load a mobile web page that gets location and works perfectly in all browsers as well in the iOS app. I believe I have all the android permissions set correctly but it is still not prompting to allow share location like the iOS app does and I believe that is why I am not getting Lat/Lng.
What am I missing?
Thanks. [import]uid: 183369 topic_id: 22565 reply_id: 137247[/import]

Ross,

Regarding JavaScript geolocation support in WebViews and WebPopups, we just added support for this now, which will be made available in daily build #1008 tomorrow. Daily builds are available to those with a subscription.

Note that you will need to enable the following Android permissions in your “build.settings” file in order to receive location data.
[lua]settings =
{
androidPermissions =
{
– Permission to access the GPS.
“android.permission.ACCESS_FINE_LOCATION”,

– Permission to retrieve current location from WiFi or cellular service.
“android.permission.ACCESS_COARSE_LOCATION”,
},
}[/lua]
[import]uid: 32256 topic_id: 22565 reply_id: 139529[/import]

Ross,

Regarding JavaScript geolocation support in WebViews and WebPopups, we just added support for this now, which will be made available in daily build #1008 tomorrow. Daily builds are available to those with a subscription.

Note that you will need to enable the following Android permissions in your “build.settings” file in order to receive location data.
[lua]settings =
{
androidPermissions =
{
– Permission to access the GPS.
“android.permission.ACCESS_FINE_LOCATION”,

– Permission to retrieve current location from WiFi or cellular service.
“android.permission.ACCESS_COARSE_LOCATION”,
},
}[/lua]
[import]uid: 32256 topic_id: 22565 reply_id: 139529[/import]