Skip to first unread message

Gwmsurvey Bvba

unread,
Feb 13, 2017, 12:53:16 PM2/13/17
to MIT App Inventor Forum

I start the app with a screen with a listview in which the user can select an item, after picking i read the complete data from csv and save the parts the csv into tinydb and open a new screen. 

the second screen reads the data from tinydb and fills the objects with their corresponding Tinydb values during screen initialise

on the second screen there are 2 listpickers, whenever is use them after picking the screen inialize is triggered restoring screen to the original values and the selected item is lost or changes in textboxes are lost


I already tried 

1) saving new values to tinydb in afterpick with wait procedure to be sure it's not a time issue (tested upto 10 seconds)
2) set  value to variable useagain to true in afterpicking and beforepicking that indicates that it's not first screenload and use it in  screen initialize with if then but value always is false

How can i avoid screen initialize being triggered after list picker
blocks.png

Ghica

unread,
Feb 13, 2017, 1:02:49 PM2/13/17
to MIT App Inventor Forum
Take out your delay and wait procedures!!!
Search the forum to find out why these are BAD and wil like crash your app.
When that is done try again and report here if you still have problems.
Cheers, Ghica

Gwmsurvey Bvba

unread,
Feb 13, 2017, 2:31:30 PM2/13/17
to MIT App Inventor Forum
thanks for your reply, i know why i should not use these, i only added them for testing after discovering the problem to be sure that it is not a because events are not completed before the screen initialize is triggered and executed.

Result is the same after removing the wait and delay. screen initialize is triggered, data is read again from saved values in tinydb but new values in afterpick are not saved and value of useagain is not set to true.

Giving up for today , will try again tomorow







Ghica

unread,
Feb 13, 2017, 4:58:19 PM2/13/17
to MIT App Inventor Forum
Look at the way you are screen switching: http://puravidaapps.com/manager.php
Also, in the initialize you could find out whether you did the initialize already, for example by saving something in the TinyDB.
After looking at this, post your blocks again, if you still have problems.
Cheers, Ghica.

Gwmsurvey Bvba

unread,
Feb 14, 2017, 5:55:21 AM2/14/17
to MIT App Inventor Forum
i changed the blocks as suggested now usedagainvalue is set to true and found on screen initialize

The result now is that all datafields are empty because all variables are lost , 

i could read the tinydb again but  then changes are lost 

so that means i also have to save the newvalues for each field to tinydb and compare the new values with the original value at screen.initialize which make it more complicated then necessary they also have to be reset when screen is closed

logically i do not leave the screen bij activating a listpicker so i do not understand why screen initialize is triggered







screen3.png
screen4.png

Gwmsurvey Bvba

unread,
Feb 14, 2017, 7:02:19 AM2/14/17
to MIT App Inventor Forum
i created a new project with limited code to simulate the problem

when i use the listpicker here it returns to the screen without triggering screen initialize so what is the difference with my other app

code ends in screen.inititialize and there is no additonal code executed after picking the list

i also test with the new showlistasjason which makes no difference

SCREEN6.png

Taifun

unread,
Feb 14, 2017, 8:57:57 AM2/14/17
to MIT App Inventor Forum
when i use the listpicker here it returns to the screen without triggering screen initialize 
that's the normal behavior

so what is the difference with my other app
probably you have a clock component running there?
you also might want to test using a device or after building the app (apk file)

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Gwmsurvey Bvba

unread,
Feb 14, 2017, 10:14:42 AM2/14/17
to MIT App Inventor Forum
There is a clock component in the screen but it's only used to get systemdate in case value is not in tinydb. In the tests value was always available

i tested the app on emulator, Ai Companion and Installed from apk on device

Always same result
clock.png

Taifun

unread,
Feb 14, 2017, 10:45:43 AM2/14/17
to MIT App Inventor Forum
without looking into your project it seems to be not possible to find the problem
unfortunately I do not have time to do that
probably someone else can help you...

Taifun

Ghica

unread,
Feb 14, 2017, 12:16:50 PM2/14/17
to MIT App Inventor Forum
I do not see the blocks that could explain your behaviour. One thing I saw in earlier blocks is a close screen. If you return to the screen just closed, you will have lost its values and it will do initialize again.
I do not have much time either this week. But you could attach an .aia that shows your problem and I will see if I can take a look.
Cheers, Ghica.

Gwmsurvey Bvba

unread,
Feb 16, 2017, 7:20:10 AM2/16/17
to MIT App Inventor Forum
Thanks for your reactions, i will rebuild the code from scratch

Gwmsurvey Bvba

unread,
Feb 16, 2017, 11:59:39 AM2/16/17
to MIT App Inventor Forum
FYI

enabled all blocks exept screen initilize and listpicker.afterpick and it still does the same

As said i think only solution will be rebuilding from scratch
blocks (1).png

Gwmsurvey Bvba

unread,
Feb 23, 2017, 6:05:32 AM2/23/17
to MIT App Inventor Forum
fyi

I rebuilded the sreen from scratch with the same objects and same objectnames then i copied the blocks from the original screen to backpack and to the new screen.

everything works again as it should.


Reply all
Reply to author
Forward
0 new messages