Evening livecoders
Well I'm here again, its heading towards 1 in the morning and I'm stumped again. As ever any help would be very much appreciated:
I am making an api call to google distance matrix, it works fine on the desktop, but not on android. As far as I can tell nothing is returned??!!!!
The code is-
command check_distance_to_school_only
if the environment is "mobile" then
set the defaultFolder to specialFolderPath("external documents")
end if
put URL ("file:saved_currentlocation.txt") into tphone_location
put URL ("file:saved_school_location.txt") into tschool_location
put URL ("file:saved_school_geof_size.txt") into tgeof
put "https://maps.googleapis.com/maps/api/di ... n?origins=" & tphone_location & "&destinations=" & tschool_location & "&mode=walking&key=AIzaSyCF13NFbjMMz7zETlkSoMpuIdVjYr8a9Ew" into tlocation_request
put URL (tlocation_request) into tlocation_response --NOTE just put brackets in to check
put jsontoarray(tlocation_response) into tdistance_Array
put tdistance_Array["rows"]["1"]["elements"]["1"]["distance"]["value"] into tdistance_from_school
put tdistance_from_school into URL ("file:saved_current_distance_from_school.txt")
if tdistance_from_school <= tgeof then
put "in school" into URL ("file:saved_current_location_type.txt")
else
put "out of school" into URL ("file:saved_current_location_type.txt")
end if
end check_distance_to_school_only
Thanks again
Paul
api call not working on android
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: api call not working on android
Hi Paul,
Not sure that is the issue but as far i know specialFolderPath("external documents") doesn't exists.
You maybe mean specialFolderPath("documents")
Best regards
Jean-Marc
Not sure that is the issue but as far i know specialFolderPath("external documents") doesn't exists.
You maybe mean specialFolderPath("documents")
Best regards
Jean-Marc
https://alternatic.ch
Re: api call not working on android
Heya J-M, it apparently exists now.
You said it works "fine on the desktop", are you talking about from within the IDE, run from an emulator, or run as an actual desktop standalone? Would also be helpful to know which vers. of Lc your running, although I suspect it is one of the more recent versions since, as Jean-Marc said, that special folder path wasn't around very long.
Sorry Paul, I have no contribution to your actual issue.Dictionary wrote: On Android systems, note that the file system is case-sensitive.
<sic>
The following folderIdentifier values are supported:
"documents": The folder where application-specific data can be placed (typically valuable)
"cache": The folder where transient application-specific data can be placed (typically not valuable)
"temporary": Same as "cache"
"engine": The (virtual) folder containing the application's LiveCode engine and other resources that were copied into the application at build time
"resources": Same as "engine".
"external documents": The folder on the primary shared/external storage device where application-specific data can be placed
"external cache": The folder on the primary shared/external storage device where transient application-specific data can be placed
"external temporary": same as "external cache"
Note: If using any external folderIdentifier values, ensure you have the 'Write External Storage' permission checked in the application standalone settings
You said it works "fine on the desktop", are you talking about from within the IDE, run from an emulator, or run as an actual desktop standalone? Would also be helpful to know which vers. of Lc your running, although I suspect it is one of the more recent versions since, as Jean-Marc said, that special folder path wasn't around very long.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: api call not working on android
Thanks Bog, dictionary is my friend... until the end of the text (as far I know)
I can see it in LC 8.1.9I suspect it is one of the more recent versions
https://alternatic.ch
Re: api call not working on android
Heh, I think we have all had it happen Jean-Marc. I know I've gotten it wrong even reading the dictionary entry, just because of the wording used and my interpretation of it, so don't feel all alone
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: api call not working on android
I tend to avoid setting the defaultfolder, especially on mobile. You might try using the complete file path:
put specialfolderpath("external documents") & "/saved_current_distance_from_school.txt" into tPath
put tdistance_from_school into into url ("file:" & tPath)
If that doesn't work try adding a slash or two: "file://"
put specialfolderpath("external documents") & "/saved_current_distance_from_school.txt" into tPath
put tdistance_from_school into into url ("file:" & tPath)
If that doesn't work try adding a slash or two: "file://"
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com