Page 1 of 1
Location results empty
Posted: Tue Jul 18, 2017 2:15 pm
by Scoperzor
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?
Re: Location results empty
Posted: Wed Jul 19, 2017 6:09 am
by strongbow
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
Re: Location results empty
Posted: Wed Jul 19, 2017 6:37 am
by Scoperzor
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
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.
Re: Location results empty
Posted: Wed Jul 19, 2017 7:12 am
by strongbow
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.
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
Other than that, perhaps try changing your other params to "true" instead of "false" and see if there's any difference.
HTH
cheers
Alan
Re: Location results empty
Posted: Wed Jul 19, 2017 7:32 am
by Scoperzor
Let me show you the code so you have full clarity:
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
button "CheckLocation"
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
Every single one of these variables returns empty.
Re: Location results empty
Posted: Wed Jul 19, 2017 12:16 pm
by strongbow
Have you tried putting in the card script:
Code: Select all
on trackingError pSensor, pError
answer "There was an error with sensor" && pSensor && pError
end trackingError
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
Re: Location results empty
Posted: Wed Jul 19, 2017 12:47 pm
by Scoperzor
Yeah I have tried those too already, unfortunately. On openCard:
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
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.
Re: Location results empty
Posted: Wed Jul 19, 2017 1:05 pm
by strongbow
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
Re: Location results empty
Posted: Thu Jul 20, 2017 1:45 pm
by Scoperzor
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
No luck with that either.
Re: Location results empty
Posted: Thu Jul 20, 2017 2:18 pm
by strongbow
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!
Re: Location results empty
Posted: Fri Jul 21, 2017 1:08 pm
by Scoperzor
strongbow 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!
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=20120