Location results empty
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Location results empty
Hi, having trouble returning location results on an Android tablet (Samsung SM-T819, Android version 6.0.1)
Built a new stack and did the following:
Ran mobileStartTrackingSensor "location", false
Checked mobileSensorAvailable("location") and mobileCanTrackLocation(), both returned true.
Then "put mobileSensorReading ("location", false) into theLocation" - theLocation is empty for all keys
"mobileCurrentLocation()" is also empty for all keys
Checked app permissions and both types of tracking are required, checked tablet settings and confirmed app is set to allow location tracking.
Any idea?
Built a new stack and did the following:
Ran mobileStartTrackingSensor "location", false
Checked mobileSensorAvailable("location") and mobileCanTrackLocation(), both returned true.
Then "put mobileSensorReading ("location", false) into theLocation" - theLocation is empty for all keys
"mobileCurrentLocation()" is also empty for all keys
Checked app permissions and both types of tracking are required, checked tablet settings and confirmed app is set to allow location tracking.
Any idea?
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Mon Jul 31, 2006 1:39 am
- Location: New Zealand, Australia, Germany, Japan
- Contact:
Re: Location results empty
Did you allow a little time for the sensor tracking to start up? Start it up in on opencard and then have a button to repeatedly try to get the current location. I've found that the first time is often empty but later ones get data.... but YMMV.
cheers
Alan
cheers
Alan
Re: Location results empty
Yup, I did try that too. The start sensor command I put in one button, and then in another button I added a loop to check every 5 seconds for locations.strongbow wrote:Did you allow a little time for the sensor tracking to start up? Start it up in on opencard and then have a button to repeatedly try to get the current location. I've found that the first time is often empty but later ones get data.... but YMMV.
cheers
Alan
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Mon Jul 31, 2006 1:39 am
- Location: New Zealand, Australia, Germany, Japan
- Contact:
Re: Location results empty
1 question: as the data is returned in an array, what did you do to see the data? If you just printed the variable theLocation, it will be empty. You need to look at the keys + values of theLocation (if you didn't already).
e.g.
Other than that, perhaps try changing your other params to "true" instead of "false" and see if there's any difference.
HTH
cheers
Alan
e.g.
Code: Select all
put mobileSensorReading("location", true) into theLocation
repeat for each line tKey in the keys of theLocation
put tKey && theLocation[tKey]
end repeat
HTH
cheers
Alan
Re: Location results empty
Let me show you the code so you have full clarity:
button "CheckLocation"
Every single one of these variables returns empty.
Code: Select all
on mouseUp
mobileStartTrackingSensor "location", false --replaced with true in another test, same result
put "Sensor:" && mobileSensorAvailable("location") & cr & "Can track location:" && mobileCanTrackLocation() into field "Permissions"
put the text of field "Seconds" into tSeconds
send mouseUp to button "CheckLocation" in tSeconds seconds
end mouseUp
Code: Select all
on mouseUp
put mobileSensorReading ("location", false) into theLocation
put the keys of theLocation into tKeys
put theLocation["latitude"] into theLat
put theLocation["longitude"] into theLon
put theLat && theLon && "(keys: " & tKeys & ")" into field "Location"
put mobileSensorReading ("location", true) into theLocation
put the keys of theLocation into tKeys
put theLocation["latitude"] into theLat
put theLocation["longitude"] into theLon
put cr & theLat && theLon && "(keys: " & tKeys & ")" after field "Location"
put mobileCurrentLocation() into theLocation
put the keys of theLocation into tKeys
put theLocation["latitude"] into theLat
put theLocation["longitude"] into theLon
put theLocation["horizontal accuracy"] into theAcc
put cr & theLat && theLon && theAcc && "(keys: " & tKeys & ")" after field "Location"
end mouseUp
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Mon Jul 31, 2006 1:39 am
- Location: New Zealand, Australia, Germany, Japan
- Contact:
Re: Location results empty
Have you tried putting in the card script:
Otherwise not sure. Are there any sample stacks from Livecode that you can try? Or any other phone you can try it on?
cheers
Alan
Code: Select all
on trackingError pSensor, pError
answer "There was an error with sensor" && pSensor && pError
end trackingError
cheers
Alan
Re: Location results empty
Yeah I have tried those too already, unfortunately. On openCard:
They don't seem to ever be triggered, despite me walking around outside with the device. I've tried 3 different tablets now, two Samsungs with Android 5/6, and one Lenovo with Android 6, all do the same thing. I'm pretty stumped, so I've added a bug report for it in the hopes the devs can supply me some feedback. Thanks anyway for trying to assist.
Code: Select all
on locationChanged pLatitude, pLongitude, pAltitude
put cr & pLatitude && pLongitude after field "Location"
end locationChanged
on trackingError pSensor, pError
put cr & pSensor && "reported" && pError after field "Location"
end trackingError
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Mon Jul 31, 2006 1:39 am
- Location: New Zealand, Australia, Germany, Japan
- Contact:
Re: Location results empty
Try having the scripts where you start tracking also at the card level. It vaguely rings a bell that I ended up having to have them at that level and that's where all messages are sent to. Or maybe even at stack level. That's my last suggestion (I think!).
cheers
Alan
cheers
Alan
Re: Location results empty
No luck with that either.strongbow wrote:Try having the scripts where you start tracking also at the card level. It vaguely rings a bell that I ended up having to have them at that level and that's where all messages are sent to. Or maybe even at stack level. That's my last suggestion (I think!).
cheers
Alan
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Mon Jul 31, 2006 1:39 am
- Location: New Zealand, Australia, Germany, Japan
- Contact:
Re: Location results empty
Did you confirm that you have location services activated on your devices? Not sure what you do exactly on Android but know from past apps that sometimes people have location services turned off and don't realise it. Other than that, not sure what else to check. Can you post your app somewhere or try it out on an iphone perhaps? Or an Android phone?
cheers!
cheers!
Re: Location results empty
Location permissions are enabled for the app. Location methods are also set to high power (GPS/WIFI/Mobile). The code works perfectly on iOS. I'm busy discussing it in a bug report here: http://quality.livecode.com/show_bug.cgi?id=20120strongbow wrote:Did you confirm that you have location services activated on your devices? Not sure what you do exactly on Android but know from past apps that sometimes people have location services turned off and don't realise it. Other than that, not sure what else to check. Can you post your app somewhere or try it out on an iphone perhaps? Or an Android phone?
cheers!