api call not working on android

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
paulalsmith1000
Posts: 52
Joined: Sat Jun 15, 2019 10:09 am

api call not working on android

Post by paulalsmith1000 » Sat Jan 04, 2020 1:27 am

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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2459
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: api call not working on android

Post by jmburnod » Sat Jan 04, 2020 9:51 am

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

bogs
Posts: 4615
Joined: Sat Feb 25, 2017 10:45 pm

Re: api call not working on android

Post by bogs » Sat Jan 04, 2020 10:27 am

Heya J-M, it apparently exists now.
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
Sorry Paul, I have no contribution to your actual issue.

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.
Image

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2459
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: api call not working on android

Post by jmburnod » Sat Jan 04, 2020 10:46 am

Thanks Bog, dictionary is my friend... until the end of the text (as far I know) :oops:
I suspect it is one of the more recent versions
I can see it in LC 8.1.9

bogs
Posts: 4615
Joined: Sat Feb 25, 2017 10:45 pm

Re: api call not working on android

Post by bogs » Sat Jan 04, 2020 10:51 am

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 :wink:
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5344
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: api call not working on android

Post by jacque » Mon Jan 06, 2020 9:00 am

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://"
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Internet”