[Solved] How do I use Google Sheets on a device?

Hello everyone!
Hope evryone is doing wel.
I have a bit of a problem.
I’ve created a random qoute system that uses google sheet to get the qoutes
and then displays a random qoute in the button.
It works as supposed on the web-preview but when I download it it doesn’t work on my chromebook or android phone.
here are my blocks:


how do i fix this?
Thanks

1 Like

Hi @sketch

Can you try download and test one of these wdc quote apps that are powered by Google Sheets:

Also, I’ve never tried the device is online block on a Chrombook so that’s another thing that would be worth looking into!

2 Likes

Can you explain what you mean by “doesn’t work”?

If you’re getting a white screen or crash message, I suspect that you need to see if the stored variable is NULL before you try to get its length. That’s probably crashing your app.

1 Like

hi
I think i may have found the problem, you can’t do length of a variable that is not a list, so you might want to set it to an empty list and then while setting it to something, i would add to list, instead of setting the variable to the value.

2 Likes

It works in the web preview because while you are developing and testing you have updated the stored variable and it reported something other than null.

When you moved to your mobile or Chromebook, There is no stored variable saved for your app and therefore the app failed.

Just as @catsarisky advised, manage your use of stored variable by testing for null prior to assigning it anything or using it for anything and your app should work as expected.

2 Likes

@sketch
I took the liberty of checking out your project by your username and I edited it. It seems to work now.

The link is here
PS - i duplicated your project and all i got from the data is thunkable so thats it that is in the quotes

3 Likes

:facepunch: :slight_smile:

thank you so much that works.
Still one qeustion is there a way to remove the Delay before IT picks a random qoute?

It seems to work for me.

I didn’t quite understand what you meant, but you could always remove the wait 5? And i to have a question for you, is there a specific reason why you do function quote twice?

Just so you don’t have to see the qoute for 10 seconds.

I have a button that displays the qoute.
But When i open the app IT waits 2 seconds before change to nothing.
And Then another second before picking a random qoute.
Sonetimes IT Just hangs at a empty button.

When I live tested it, it comes almost immediately, and one last question, do you want the user to wait 10 seconds or can you just speed up that process by removing one of the wait 5.

that doesn’t seem to be my case.

I can speed it a bit up.

To prove my point, I opened network in web development tools, all the packets that are being requested are coming in a matter of milliseconds, only your logo took about 246 ms, that is


still less than a second, also some other packets are taking 0ms

hmm i did the same check it says that it took 1.7 minutes to load.

I was just looking at your code and wondering, do you have to set a stored variable to the quotes or can you just call directly from google sheets? Unless you have planned for offline use.

minutes or microseconds?

minutes.

I do plan to do that.

then, unless you are constantly updating, you could set your quotes in that variable, as i had set it to empty list in the top most part of the code. And if you actually want random quotes i would suggest web api. And unless you are planning to do something with the button, i would use a label if i were you.

Yeah.
But i wil leave IT like this.
Also the Delay is gone now.
I gues IT was Just a wifi problem.
Thanks for helping!

2 Likes

The label is broken for me so i use this workaround.
IT doesn’t change position or size like the button does.