2016년 11월 29일 화요일

Getting RSS Feeds?


Hi, all.  I am a brand new App Inventor user.  I started learning it about a week now.  I was wondering if it is possible to get a list of RSS feeds from a website and then display them in an app?  I think it has something to do with the listview, but I am not sure.  Anyone have any ideas?  

--
Check this link https://groups.google.com/forum/#!searchin/mitappinventortest/rss/mitappinventortest/kdleVpIJqwc/tMige1k4N5gJ

Searching forum before posting question will really save time.


-- 

How do it.. (for traffic lights)


How can I add blocks to get this: I want app will monitor the traffic lights (visually) and when the light changes eg from red to green, the play sounds. How should I go about? It is my second app so I'm very new! Please help me.

-- 
How are your traffic lights represented? How do you find out if they change?
Cheers, Ghica.

-- 
I have on my job the red and green light. when it switches so I would like to get the sound signal so I know when it's time to work, :) and I do not have to sit and stare at the lamp all the time. it is precisely the change of color is interesting from red to green. or red fails it will be the same thing, it will attract attention.

-- 
Are you sure you need an app for that?
In my town, the honking behind me tells me the light has changed.
ABG

-- 
Sorry Sebastian, your traffic light project is not practical using any reasonable methods.

1) How will the app determine the light has changed? 
 Do you expect the Camera to take a picture,save it, then compare the red amber or green pixels? You have to point the Camera, find a way to recognize it is 'looking at' a traffic signal, decide whether the signal is red or whatever.
Does the city provide a datastream showing the status of traffic signals?  Probably not.

2) If you app 'makes a mistake'  is it all right for the user to have an accident or cause a death?

It is a real neat concept, unfortunately AI2 and probably no Android can determine the status of the traffic light.

Perhaps someone has some ideas how this could work (other than the user looking at the light, deciding the color has changed, pressing a button to send a vocal message using TTS to say the light has changed and play sounds?   The sound playing is easy to program with AI2,  determining that the light actually changes is probably impossible.

Regards,
Steve

-- 
its not in traffic.. its on my job...

-- 
OK   ... then you might try to find an example from the MIT  Gallery of AI2 user provided examples.  See if someone has already made an app like you would like to make.

Search in the Gallery    using the term    time management        or    schedule    or   alarm  or perhaps   camera .  The examples might be what you want.  Find something interesting; download the aia and try the app, then modify it to do what you want perhaps?  You probably can think up other search terms.

How do you search the Gallery?    Load the AI2 browser.  then as shown below...


Or something similar.    You can use a Clock component to keep track of time.    There is no control to keep track whether a room perhaps is illuminated or dark.   You can set an alarm using a Clock component (in the Sensor drawer).

Using the camera to determine if an image is light or dark would probably be very complicated.   You could search a camera image for  light or dark pixels but if you use the camera, you will already know.  What you might do is use an arduino or other mini computer that has a light sensor and use that to determine if it is getting dark or bright and when the light level is at a certain level, to sound an alarm.

Good luck Sebastian.

-- 

I respectfully disagree with SteveJG.

As far as I understand this:
- point your phone at the traffic light, which is positioned on your workfloor somewhere for all workers to see.
- Let the camera of your phone monitor the traffic light, by taking pictures at regular intervals and interpreting them for change.
- If the light changes from red to green, speak a message: Go to work! or similar.
- If the light changes from green to red, speak a message: Coffee time! or similar.

This should be doable but not easy. And probably not very practical, because it would need
Start with a good understanding of AI, if needed look here: http://appinventor.mit.edu/explore/ai2/tutorials.html
Then, Taifun should be your best friend. He has extensions to make your life easier: http://puravidaapps.com/extensions.php
Maybe it is as simple as using this one: http://puravidaapps.com/image.php
This one: http://puravidaapps.com/snippets.php#2screenon
or maybe this extension: http://puravidaapps.com/file.php can help you to store a new and a previous camera image, or maybe just the file component is enough.
Maybe this tutorial can be of help: http://puravidaapps.com/file.php
And this: http://puravidaapps.com/snippets.php#2canvas
There are also some threads in this forum that talk about recognising shapes or colors in an image.

Now, would it be practical? The app should stay on the foreground (it needs to monitor the traffic light, right?), which means you cannot do anything else with your phone and it will drain your battery. So you really would need a dedicated phone for this, attached to a power supply.
Would it not be simpler to ask management to sound an alarm, in addition to switching the light?

Cheers, Ghica.


-- 

Webviewer issue with local html files


Hi folks.

I'm developing an app that uses webviewer to view html files located in the assets directory. Initially, it reads html files included as assets in the app apk file. This works fine and the hrml files display fine.

Twice a month, the app runs a check with my web server to download the latest version of these html files. It uses the web component to get the files and store them in the assets folder. This works fine - the files download and are stored in the assets dir.

The new html files can be viewed using the android file manger, which confirms that they're in the assets dir and I cannot see the old ones there (they must be overwritten - which is fine, as I only want one version there at any one time), BUT, and this is the problem, when you load the app and try to view the files through it, it displays the original html files that were packaged with the app and not the new ones downloaded from the server.

I looks like the app or webviewer component is caching the files somehow, but it's not that straightforward as my app runs the download on first run as well (if there's a net connection), so the new html files should be downloaded to the assets dir before the web viewer even opens them for the first time.

Does anyone know what's going on here? I have html meta commands in the html files to try to force no caching etc., but that makes no difference. I'm pulling my hair out here!

Any help would be much appreciated :)

Thank you.

-- 
These are the blocks that locate the html files and display them in the webviewer component.
Capture.PNG 표시 중

-- 
In trying to work out wht's going on, I have found that if I delete the Appinventor dir on the phone or tablet that I'm testing the app on - the folder that contains all of the assets - the app still works fine and displays all of the images, html files etc. that I've deleted! I thought that perhaps the system or app has cached the assessts somewhere else, but I cannot find them. Stranger still, when I uninstall the app on both the phone and tablet, then reinstall, the Appinventor dir is not created. If fact, there's no trace of appinventor assets anywhere on the phone, yet the app still works and all of the assets still display (but not the ones that download from the internet on first run, as per my original problem). Does anyone know what might be going on here?!  

-- 
I have bottomed out the issue. I was mistaking the Companion App dir on both the tablet and phone as being the asset store for the app. That explains why files saved into that dir are not read by the app as assets. Ignore my original questions! :)

-- 

 the files download and are stored in the assets dir.

no, after building your app the assets are read only, you only can download to sdcard!


I looks like the app or webviewer component is caching the files somehow

therefore your app will still access the old files from the assets

Taifun

-- 

Add line space between text strings from Fusion Table


Hi,
My app returns strings of text from a Fusion Table and shows them in a label text box but they would read better if each sentence is separated by a space. Is there any way to do this without using lists? I've tried lists but couldn't get them to work.
Thanks, Kris
blocks (7) cropped.png 표시 중
-- 
What does your output really look like? Why did the lists not work?
Using the text component you could replace . by . followed by a space, or \n (new line).
Cheers, Ghica.

-- 

• How to work with Lists by Saj


Taifun

-- 
For a vertical space, use \n\n

Alternatively, turn on the html attribute of your label and use <br><br>

ABG

-- 
The output looks like a series of sentences all jammed together vertically. I think I tried adding in an \n to the text in the fusion table, but will give it another look. Thanks.

-- 
Thanks. I'll try getting the lists to work. I did all the tutorials and read all the references I could find when I first got into this a few months ago, and tried coding for lists, but then concentrated on getting the rest of the App to work. 

-- 
Thanks I'll use one of those.

-- 
I used lists to get the spaces between lines and list of lists to remove the brackets. See attached block. Thanks for replies. 
blocks (8) cropped.png 표시 중

-- 

countdown.. but how?


it is possible to create a countdown to a specific time, so how do you do that? not to be confused with the countdown of the set time in standard timer. I put 28 minutes and it will count down from there. I will therefore that it must rely more time remaining to a specifick heel impact. for example, at 4:23 then starts a television program that I would like to know the exact time that is left until then. are you with me on this problem?

-- 
It does not look like you have used the forums yet, as a search using the search box above would have returned several threads about this topic.

Taifun

-- 
i´m so sorry...

have read this thread ... the problem is how I can put time as the target for the countdown. user to select / enter the time when the timer is the goal.

i can´t find similar project..

-- 
use the time picker component http://ai2.appinventor.mit.edu/reference/components/userinterface.html#TimePicker

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  
How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling.

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the
 Top 5 Tips: How to learn App Inventor


You will not find a tutorial, which does exactly what you are looking for. But doing the tutorials (not only reading a little bit) help you to understand, how things are working. This is important and this is the first step to do.

Taifun    

-- 
thx

-- 

Local server error: Server error: could not upload project. Please try again later


I'm running appinventor locally. When I'm uploading project from  ai2.appinventor.mit.edu. Project is 2 weeks old. I'm getting "Server error: could not upload project. Please try again later!" error message.

More detailed error message:
Nov 29, 2016 12:09:17 AM com.google.apphosting.utils.

jetty.JettyLogger warn
WARNING: /ode/upload/project/myapp
com.google.appengine.tools.cloudstorage.NonRetriableException: java.lang.IllegalArgumentException: operating on too many entity groups in a single transaction.

Uploading from repository works fine.

What can be causing this behavior? Server most certainly is not under heavy load.
What I tried so far:
Switch browser (Chrome, Firefox, Opera)

I'm running:    Ubuntu 16.04.1 LTS
Java version "1.7.0_80"
Apache Ant(TM) version 1.9.6 compiled on July 8 2015
appengine-java-sdk-1.9.46 - 2016-11-01

Video:
https://youtu.be/Rgzu8n_usrQ

Thanks~




--
have you tried more than one aia file? It might be an issue with the one you are trying to upload.
Does it use an extension or similar? Any code that is not in your
local server or have you modified any of the components?

If you've modified any of the ones you are using in that aia file, it
will have a hard time loading it.

cheers,
José


--
Yes, your right, other .aia files seems to work fine. Oh, by the way, there is no external extensions, modifications or components. What can be causing this error?

--
where was that aia originally created? local server? if you haven't
changed anything, and it was created in the same server, then it's odd
that it is not loading.

cheers,
José

--
Original file was created on http://ai2.appinventor.mit.edu website about two weeks ago.

--
does it load in there?

cheers,
José

--
Yes, It loads and runs on my phone, also I can upload that specific .iai file to http://ai2.appinventor.mit.edu

--
Maybe there is upload size restriction on local appinventor server?
I'm uploading 3.0MB .iai file.

--
I think too many media upload elemets was causing:
java.lang.IllegalArgumentException: operating on too many entity groups in a single transaction.
There was about 40 or more media elements, after deleting large number of then, upload to local server was successful.

--
I believe I understand what is happening here.

AppInventor is hosted on Google’s App Engine system. App Engine places
strict limits of how long a single transaction can run (60
seconds). As you build your project you add blocks and upload
assets. Each of these operations runs in a small amount of time.

However when you attempt to upload a .aia file with a lost of assets,
the upload is one transaction. If there are a lot of images, it takes
awhile for these to get uploaded (another Google restriction). If the
sum of the upload times exceeds 60 seconds, the transaction is
terminated and your project upload fails.

We are looking at several alternatives to avoid this problem, but for
now there isn’t much we can do about it.

You are welcome to try uploading your project to
code.appinventor.mit.edu. This is a re-implementation of MIT App
Inventor which is not running in App Engine and doesn’t have the App
Engine related restrictions.

-Jeff

P.S. code.appinventor.mit.edu is reasonably stable, but we will be
updating it this week, including moving it to different hardware, so
there may be some (hopefully short) downtime.


Nir Vana writes:
> Yes, It loads and runs on my phone, also I can upload that specific
> .iai file to http://ai2.appinventor.mit.edu



--

Using TinyDB with buttons


Hi there,

I am currently creating an app which is meant for drivers. Currently, I am wanting to create a on/off button to turn of the features, I have attached an image of the blocks and I have marked in a red pen the blocks for the on/off buttons. Now that is done, I wish to use TinyDB to save the users option for when they leave/close the app, the thing is, I do not know how to apply TinyDB to the buttons (I have used it for something else in the app but applying it to the buttons seem harder), could somebody kindly please help me with this.

Thanks.

Image of button in designer.JPG 표시 중

Blocks.JPG 표시 중

--
what about using only one button and changing the button text and color accordingly?
concerning TinyDB, see here TinyDB tutorial by Stephen
jusgt store on or off in a TinyDB tag of your choice and read it again in Screen,Initialize...

Taifun

-- 
Taifun, can you still use two buttons like me and use TinyDB?

Thanks.

-- 
yes you can
Taifun

-- 
Ok Taifun, 

I am just going to use the two buttons as so, I do know how to use TinyDB but I am just struggling using it with this particular two buttons. Are you able to guide me briefly?

Thanks.  

-- 
 Taifun wrote:
yes you can
Taifun

Ok so, I attempted to do it (I've attached an image of the blocks) but for some reason when you leave the app, none of the on and off button appears, what am I doing wrong? 

Thanks.
Blocks.png 표시 중

-- 
if you want to store 2 tags in TinyDB, then you have to store both in the On.Click and Off.Click event
btw. you can do the same with only one tag, because if On is true, then Off is always false...
Taifun

-- 
 Taifun wrote:
if you want to store 2 tags in TinyDB, then you have to store both in the On.Click and Off.Click event
btw. you can do the same with only one tag, because if On is true, then Off is always false...
Taifun



To be really honest Taifun, I don't know what you mean.  Can you please refine it?

Thanks.

-- 
Jude G wrote:

UTC+11, Taifun wrote:
if you want to store 2 tags in TinyDB, then you have to store both in the On.Click and Off.Click event
btw. you can do the same with only one tag, because if On is true, then Off is always false...
Taifun

To be really honest Taifun, I don't know what you mean.  Can you please refine it?

Thanks.



Okay, so I placed adjusted the tags for TinyDB (refer to attachment) but this time when you open and then close the app, both buttons appear! Now what am I doing wrong?

Thanks.
Blocks.png 표시 중

-- 
What is the purpose of having one button for ON and another for OFF? You can't have ON and OFF being true at the same time.

Why not a single switch button? Isn't that easier? (Please download the aia file and try it)

 Capture.jpg

-- 
 Italo wrote:
What is the purpose of having one button for ON and another for OFF? You can't have ON and OFF being true at the same time.

Why not a single switch button? Isn't that easier? (Please download the aia file and try it)





Hello Italo,

What do I put in the 'valueIfTagNotThere'. I want it to display 'off' if it can not find a tag.

See image for reference. Thanks!
Blocks.png 표시 중

-- 

What do I put in the 'valueIfTagNotThere'. I want it to display 'off' if it can not find a tag. 

OFF
Taifun

-- 
Okay thanks. When you enter the app after it being closed and had chosen the on button though, it has a red background and not a green one.

Image attached

Thanks.
Screenshot_2016-04-04-14-46-24.png 표시 중

-- 
In Screen1.Initialize, you retrieve the button text from TinyDB, good.
But you neglected to refresh the button color depending on its text.
ABG

-- 

Saving Checkmarks and data I input as a user, not through program


I am trying to save my check marks so when I uncheck them, and go to another screen, they remain unchecked.. Also I cannot figure out how to get my text to remain saved after inputting it in a text box, it just goes away...

-- 
Look for AI2 TinyDB tutorials.
refer to: https://www.youtube.com/watch?v=mKe5a8F6uvY

-- 
I tried doing it with TinyTB but it only saves it then restores it somewhere else... And doesn't work for the check marks..

-- 
To save a checkbox, save true or false under the tag equaling the checkbox text or meaning.

So if you were filling out a form for user ABG and you had check boxes "old", "young", "sweet", "cranky",
you might save them in TinyDB as tag/values like
"ABG-age"/"old",
"ABG-temper"/"cranky".

-- 
Another way you might encode your check boxes in TinyDB might be as a list of pairs, using for example my previous post...

tag: "ABG"
value:  a list of pairs:
(
("age"  "old")
("temper" "cranky")
)

This is a good organization for use with the lookup in pairs list block.

The secret to using TinyDB is to regard it as a refrigerator in a hot climate.
Put your data away in TinyB without delay, and get it out just before you use it.

-- 

This is how I got it to restore my checks after they are unchecked (I enabled and checked them in the designer screen), I cannot figure out how to get it to save my checks after I uncheck them and exit the app or leave to another screen.... I tried doing everything you said with no success, I tried typing the text with the check mark, I tried separating the check by adding text box (which is what I would like to to do because I want to b e able to add and save my text in a text box) and nothing I do makes the checks or text stay....

-- 
I have an example project for you to look at and see if you can understand what is going on to save checkbox states between screens.
I believe that you want to be able to tick the checkboxes in screen1, then open screen2 and see the checkboxes in the same state as they were in screen1.
This example project does that by saving the initial state of the checkboxes in screen1 or if they are changed in a TinyDB database.
When screen2 is opened, the checkboxes there are set to the saved states of their counterparts in screen1.
If they are changed in screen2 their new states are saved in the database also.
So when returning to screen1, the checkboxes in screen1 will be changed to reflect the new states.
Study the project, read the comment bubbles and ask here if you have further questions.

Blocks for Screen1:
 screen1.png

Blocks for Screen2:
 screen2.png

-- 
Each Screen is different and worded differently but Screen 1 is exactly what I needed! Thank You! Would you happen to know if this would work for saving text entered into text boxes?? I think not but thought because not the same concept but thought I would ask in case you know how to save the text into other text box's that is entered by the app user...

-- 
Yes you can save the text entered in exactly the same way.
When you want to save the text use StoreValue.
To restore the textbox text from the saved tag for that textbox use GetValue.

-- 
Ok, it work for the first two screens but I cannot get it to do any more screens... I am so thankful for the help..

-- 
It should work the same for other screens.
Maybe show the blocks for a screen that is not working.

-- 


Got it to work, I left out words on the text block, fixed it and got it to work, I figured out the text too, I used the "lost focus" for "changed" and adding what I need to the previous blocks, success! Thank you, Now I'm working on making it so we can add text or pick from a list, This is the best! Thanks again!

-- 
Trying to get my list picker to let me use more than one text box. I have 40 text boxes but the book I have only shows me how to select 1 item from my list.


-- 
If your 40 text boxes represent 40 of the same type of thing, you are doing multi-select.
See this app in the gallery and its doc for how to do multi-select...

If you are filling in a 40-item form, instead consider keeping the target text box components in a list,
and using the Any text Box blocks in a procedure .

-- 
Got it, I have to pick my selection then pick the box I want it to go into, Thank You!










-- 
I see from your blocks you have a TinyDB named TinyDB3.

I hope you don't also have other TinyDBs 1,2,...
They all point to the same data store.

-- 
I do because after 40 checks it didn't want to store anymore for some reason... SO it can store everything?? I figured it could but It just didnt want to

-- 
From the Designer help on TinyDB:

TinyDB is a non-visible component that stores data for an app.
Apps created with App Inventor are initialized each time they run: If an app sets the value of a variable and the user then quits the app, the value of that variable will not be remembered the next time the app is run. In contrast, TinyDB is a persistent data store for the app, that is, the data stored there will be available each time the app is run. An example might be a game that saves the high score and retrieves it each time the game is played.
Data items are strings stored under tags . To store a data item, you specify the tag it should be stored under. Subsequently, you can retrieve the data that was stored under a given tag.
There is only one data store per app. Even if you have multiple TinyDB components, they will use the same data store. To get the effect of separate stores, use different keys. Also each app has its own data store. You cannot use TinyDB to pass data between two different apps on the phone, although you can use TinyDb to shares data between the different screens of a multi-screen app.
When you are developing apps using the AI Companion, all the apps using that companion will share the same TinyDb. That sharing will disappear once the apps are packaged. But, during development, you should be careful to clear the TinyDb each time you start working on a new app.
-- 

calculate hours between two dates


Hi,
how to calculate the hours and minutes , between the two dates
Thanks!

--
Convert the dates to Instants, then to milliseconds, subtract them, and divide by the appropriate factors.

ABGblocks.png 표시 중

-- 
thank you. I hope I can handle it.

-- 
I fail to get along . I need to introduce the starting date and time off with DatePicker and timepicker.

-- 
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

Taifun

-- 
Here is another example. It calculates the days, hours, minutes and seconds between now and Jan 1st 2017. You can easily adapt the start and end values.
And here are the relevant blocks:

 Snap2.png

Cheers, Ghica.


-- 

this is what we managed to do. anyway thanks for the help.
 block3.png


-- 

I corrected that and now it works perfectly
 block4.png


-- 
What happens if a flight extends from 12 PM to 1 PM?

ABG

-- 

interesting

-- 
but I use the 24 hours format

--