Android put URL command fails

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Android put URL command fails

Post by Simon Knight » Fri Feb 24, 2012 11:34 am

Hi,
I have a field on a card that holds a URL e.g. http://123.345.67.890/output.txt I am using the following line to download the datafile output.txt .

Code: Select all

put url fld"fldMyURL" into tBcnData
I then process the data which is now in my variable. This works fine on the desktop (Mac) but when the application is loaded on to an Android Tablet or the emulator the line fails to get any data.

I have tried building the app with and without the "Internet" script library - the dictionary is a little ambiguous on if its needed and I confirm that the internet permission is ticked on the android build page.

Any thoughts?
best wishes
Simon
best wishes
Skids

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Android put URL command fails

Post by Simon Knight » Fri Feb 24, 2012 11:48 am

I have just discovered that if I encode the URL in my code e.g.

Code: Select all

put URL "http://123.456.78.910/output.txt" into tBcnData
then it works. But if I try to use the field contents or use an intermediate variable it fails.

Simon
best wishes
Skids

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Android put URL command fails

Post by sturgis » Fri Feb 24, 2012 2:01 pm

try: put URL (field "fldMyUrl") into tBcnData --parens force evaluation of the field first.

Also make sure to put the space between field and "fldMyUrl" (was probably a typo but thought i'd point it out anyway.)
Simon Knight wrote:Hi,
I have a field on a card that holds a URL e.g. http://123.345.67.890/output.txt I am using the following line to download the datafile output.txt .

Code: Select all

put url fld"fldMyURL" into tBcnData
I then process the data which is now in my variable. This works fine on the desktop (Mac) but when the application is loaded on to an Android Tablet or the emulator the line fails to get any data.

I have tried building the app with and without the "Internet" script library - the dictionary is a little ambiguous on if its needed and I confirm that the internet permission is ticked on the android build page.

Any thoughts?
best wishes
Simon

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Android put URL command fails

Post by Simon Knight » Fri Feb 24, 2012 6:47 pm

Sturgis,

Thanks for the ideas. Unfortunately the code still fails when running under Android.

Simon
best wishes
Skids

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Android put URL command fails

Post by Klaus » Fri Feb 24, 2012 7:06 pm

Hi Simon,

what does the result say?
...
put URL (field "fldMyUrl") into tBcnData
answer the result
...

Best

Klaus

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Android put URL command fails

Post by Simon Knight » Fri Feb 24, 2012 7:31 pm

Hi,

Some updates: the "result" is empty on both desktop and Android. The blank answer dialog is displayed before the file is down loaded (on desktop), on Android no file is downloaded.

The problem stems from my field which includes some text style: I have added a second default style field dragged in from the pallet and any URL text entered here is accessed correctly on both desktop and Android. The field that is causing the problem has text set to Arial 24 point and is colour blue. I have compared the text from this field with hard coded text and they pass an If statement it seems that the style information is getting through to the URL command and causing it to fail.

Should this be reported as a bug?

Simon
best wishes
Skids

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Android put URL command fails

Post by sturgis » Fri Feb 24, 2012 7:45 pm

Hmm on windows 7, have tried everything I can think of to make it fail and can't with the exception that if I put quotes around the url string in the field then it will fail. Is it possible there is a hidden char, or some issue with the url or a single quote, or extra lines that you can't see that have data that might cause issues?

Maybe an extraneous space somewhere in the url in the non-working field that isn't in your new test field?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Android put URL command fails

Post by mwieder » Fri Feb 24, 2012 7:57 pm

Simon-

A couple of things to try here:

There may be a trailing cr at the end of the string in the variable that's causing the failure. Maybe try

Code: Select all

put url (word 1 to -1 of field "fldMyURL") into tBcnData
Second, as sturgis mentioned, there may be some other character that doesn't make the transition to text. See what this returns:

Code: Select all

put "http://123.456.78.910/output.txt" is field "fldMyURL"

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Android put URL command fails

Post by Simon Knight » Fri Feb 24, 2012 8:06 pm

Hi,
I've discovered that the first field that fails on Android had a LF tacked on to the end of the text in the field. This did not cause a problem on desktop but stopped it working on Android. I don't know how the character was added or why the string comparisons I used to debug equated to true when one side of the test had an extra character.

Thanks for all your efforts and inputs, I will be more careful in future :oops:

Simon
best wishes
Skids

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Android put URL command fails

Post by Simon Knight » Fri Feb 24, 2012 8:08 pm

Oh,

It goes without saying that I am now unable to break the code by adding the LF back in.

Simon
best wishes
Skids

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Android put URL command fails

Post by mwieder » Fri Feb 24, 2012 8:09 pm

Simon-

If it failed on Android but worked on the desktop, I think it's worth a bug report.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Android put URL command fails

Post by mwieder » Fri Feb 24, 2012 8:10 pm

It goes without saying that I am now unable to break the code by adding the LF back in.
:P

Simon Knight
Posts: 854
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Android put URL command fails

Post by Simon Knight » Fri Feb 24, 2012 8:53 pm

I will put one in. I can get it to re-occur by adding the line end in the field contents pane of the inspector.

Simon
best wishes
Skids

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Re: Android put URL command fails

Post by Fasasoftware » Fri Oct 05, 2012 8:34 pm

Code: Select all

It goes without saying that I am now unable to break the code by adding the LF back in.
Dear simon, i'm interested in your idea....can you explain me more precisely?? I don't have understood very well your solution to the problem....I have the same problem... put url don't go in android...

I'm sorry again can you tell me step by step your solution???

I thank you a lot in advance,

Lestroso :oops:

Post Reply

Return to “Android Deployment”