How to make the program wait for either a yes or no response from a Notifier

679 views
Skip to first unread message

trev park

unread,
Mar 17, 2017, 2:25:25 PM3/17/17
to MIT App Inventor Forum
Can I use a notifier to display a message and make the program pause until the notifier is acknowledged?
As it is the program continues running with the notifier on screen 

Min Sullivan

unread,
Mar 17, 2017, 2:50:37 PM3/17/17
to MIT App Inventor Forum
I'm hardy experienced, so there probably is a way, but in case there isn't you could set a global variable.  If the global variable is false, don't run code.

Abraham Getzler

unread,
Mar 17, 2017, 3:34:51 PM3/17/17
to MIT App Inventor Forum
I ran a test of the Notifier Choice block, with a Clock and a bouncing ball.
Neither stopped.

So you have to keep track of all your moving parts and stop them yourself.

See attached for The World's Dumbest Number Guesser app.

ABG

blocks.png
Capture.PNG
Number_guesser_by_Notifier.aia

Taifun

unread,
Mar 17, 2017, 3:36:46 PM3/17/17
to MIT App Inventor Forum
App Inventor will never wait...

use the Notifier.ShowChooseDialog and continue your logic in the AfterChoosing event

Taifun

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

trev park

unread,
Mar 17, 2017, 4:45:47 PM3/17/17
to MIT App Inventor Forum
If App Inventor will never wait what is the point of having When Notifier1. AfterChoosing if it never waits for an answer

Abraham Getzler

unread,
Mar 17, 2017, 4:52:00 PM3/17/17
to MIT App Inventor Forum
If App Inventor will never wait what is the point of having When Notifier1. AfterChoosing if it never waits for an answer

It's all about having an answer to the choice question, not about waiting.

So if the question is "Should I Quit?"  the Quit block would
be in the AfterChoosing event block, guarded by a test for "Yes" reponse.

You weren't considering putting the Quit block after the block where you ask the question,
were you?

ABG
 

trev park

unread,
Mar 17, 2017, 5:06:49 PM3/17/17
to MIT App Inventor Forum
No, The programs asks 30 questions, after every question is read out by the program it checks the answer given and if correct the score is increased by one, when the score hits multiples of 10 i want a popup notifier to appear and the program to wait for the acknowledge button press from the notifier before asking the next question.

Abraham Getzler

unread,
Mar 17, 2017, 5:15:42 PM3/17/17
to MIT App Inventor Forum
It's time for you to post some blocks.
Provide both a downloaded blocks image amd an exported .aia
ABG

trev park

unread,
Mar 17, 2017, 5:47:41 PM3/17/17
to MIT App Inventor Forum
blocks (3).png
test.aia

Abraham Getzler

unread,
Mar 17, 2017, 5:58:01 PM3/17/17
to MIT App Inventor Forum
(going offline for a day.  Throwing this thread up for any one available)
ABG

Min Sullivan

unread,
Mar 17, 2017, 6:02:01 PM3/17/17
to MIT App Inventor Forum
How about running the code to ask the next question in the notif's AfterPicking or whatever handler?

Min Sullivan

unread,
Mar 17, 2017, 6:03:35 PM3/17/17
to MIT App Inventor Forum
Like move the code in NewWord.Click to a function, then call that function in the AfterPicking handler as well.

trev park

unread,
Mar 17, 2017, 6:11:26 PM3/17/17
to MIT App Inventor Forum
the newword button is there to skip that question and move onto the next question so I have it set in the submit button function where it checks the answer

Min Sullivan

unread,
Mar 17, 2017, 6:23:42 PM3/17/17
to MIT App Inventor Forum
Okay.  First, why do you want two buttons, one with "O" and the other with the k?  Is there any specific reason?  I suggest using the block in screenshot two, which only displays one button.
Screen shot 2017-03-17 at 6.22.05 PM.png
Screen shot 2017-03-17 at 6.22.14 PM.png

Min Sullivan

unread,
Mar 17, 2017, 6:26:26 PM3/17/17
to MIT App Inventor Forum
I know this isn't addressing the issue you posted about, but in the notifier's afterChoosing handler you set the background image to a media file that isn't uploaded.  I think you forgot that there file.  ;)
Screen shot 2017-03-17 at 6.25.09 PM.png

trev park

unread,
Mar 17, 2017, 6:28:15 PM3/17/17
to MIT App Inventor Forum
no particular reason, id actually prefer just one button but I could not get the one you posted to work either

Min Sullivan

unread,
Mar 17, 2017, 6:30:16 PM3/17/17
to MIT App Inventor Forum
I haven't fully looked over all the code, but since you're the author and probably know it backward and forward, how about calling the GetWord function from the Notifier's AfterPicking handler?  Do you think that would work?

P.S. I notice the set bronze, set silver, and set gold blocks have warnings.  I don't see them added to this screen.  Did you accidentally delete those components?
Screen shot 2017-03-17 at 6.27.59 PM.png
Screen shot 2017-03-17 at 6.29.07 PM.png
Screen shot 2017-03-17 at 6.29.10 PM.png
Screen shot 2017-03-17 at 6.29.12 PM.png

Min Sullivan

unread,
Mar 17, 2017, 6:32:02 PM3/17/17
to MIT App Inventor Forum
As for the notifier thing, perhaps the blocks I've attached would do the trick?
Screen shot 2017-03-17 at 6.30.55 PM.png
Screen shot 2017-03-17 at 6.31.14 PM.png

Min Sullivan

unread,
Mar 17, 2017, 6:35:36 PM3/17/17
to MIT App Inventor Forum
Works for me.  :D

When the screen initializes, the current word is not spoken.  Perhaps you can add a notifier:
Click the Okay button (the button in the notifier) when you're ready to begin.

And then you can call GetWord.

On a different subject, how about making a global variable and setting it to the listFromCsvRow[list in text here]?  Then you can use the list length block in your if statement in the GetWord function.
Screen shot 2017-03-17 at 6.34.27 PM.png

trev park

unread,
Mar 17, 2017, 6:36:54 PM3/17/17
to MIT App Inventor Forum
the bronze silver and gold things are additional bits that are in the full app code and that part works without problem, what i posted is a cut down of my main program just to show the part I am having issues with.
And as for calling the getword function from the Notifier's AfterPicking handler that will not work as the notifier is only called when 10 answers have been input correct while the getword function is called to choose a new question

Min Sullivan

unread,
Mar 17, 2017, 6:43:41 PM3/17/17
to MIT App Inventor Forum
I thought that was what you wanted, to have the game go to the next word after the notifier is Okayed.  Sorry, I misunderstood you, I'm thinking.

Min Sullivan

unread,
Mar 17, 2017, 6:55:03 PM3/17/17
to MIT App Inventor Forum
I think the next step would be to explain, specifically, what you want to happen.

Min Sullivan

unread,
Mar 17, 2017, 6:56:22 PM3/17/17
to MIT App Inventor Forum
P.S.  Another question: Why do you have two TextToSpeech components?  Why do you need two?  Does one have a different setting or something?

trev park

unread,
Mar 17, 2017, 6:59:03 PM3/17/17
to MIT App Inventor Forum
the app asks questions and every 10 correct answers the notifier pops up, and the app should not ask the next question until the notifier is dismissed but for whatever reason the app still asks the next question while the notifier is active

Taifun

unread,
Mar 17, 2017, 7:00:24 PM3/17/17
to MIT App Inventor Forum



use the Notifier.ShowChooseDialog and continue your logic in the AfterChoosing event
same for silver and gold

Taifun

Min Sullivan

unread,
Mar 17, 2017, 7:00:31 PM3/17/17
to MIT App Inventor Forum
This may be just a bandage, but time the amount of time the notifier shows, and set and use clock component to wait until after the notifier's gone.

Min Sullivan

unread,
Mar 17, 2017, 7:01:44 PM3/17/17
to MIT App Inventor Forum
Nothing is being chosen, @Taifun.

Min Sullivan

unread,
Mar 17, 2017, 7:03:44 PM3/17/17
to MIT App Inventor Forum
Specifically, in submit.Click see if you're on a multiple of 10.  If so, switch the clock on and show the notif.  In the clock's handler for when the time ends, then go to the next question.

Taifun

unread,
Mar 17, 2017, 7:08:01 PM3/17/17
to MIT App Inventor Forum
the app asks questions and every 10 correct answers the notifier pops up, and the app should not ask the next question until the notifier is dismissed but for whatever reason the app still asks the next question while the notifier is active
this is because you do not continue with the logic in the AfterChoosing event
you might want to take a look at the corrected screenshot here https://groups.google.com/d/msg/mitappinventortest/ROyJZEmXUgY/oeq8EzVgGgAJ

Taifun

trev park

unread,
Mar 17, 2017, 7:10:52 PM3/17/17
to mitappinv...@googlegroups.com
wont work because the notifier is only ever called when 10 CORRECT answers have been given not every 10 questions asked.
Its getting late here so I think I will sleep on it and look at it fresh again tomorrow, I know I can make it do what I want its just figuring out what im doing wrong

Min Sullivan

unread,
Mar 17, 2017, 8:17:04 PM3/17/17
to MIT App Inventor Forum
Well then try what I suggested when you're on a multiple of 10 correct.

Yes, sleeping on it may give you a fresh view tomorrow. Good St. patrick's Day luck to you!

Taifun

unread,
Mar 17, 2017, 8:40:54 PM3/17/17
to MIT App Inventor Forum
what about this pseudo code?

if 10th correct answer 
then open notiier.ChooseDialog
else continue with your logic

AfterChososing
  continue with your logic

the "continue with your logic" part could be a procedure...

Taifun

Min Sullivan

unread,
Mar 17, 2017, 8:46:36 PM3/17/17
to MIT App Inventor Forum
But he's using alerts where there is no choosing.

trev park

unread,
Mar 18, 2017, 9:52:06 AM3/18/17
to mitappinv...@googlegroups.com
OK after sleeping on it I have come to the conclusion that the notifier will simply not do what I was hoping it will do as the notifier if called within a loop allows the loop to continue running whilst the notifier is still visible on the screen, I am therefore going to try this from another approach, its a bit more complex for me to do but it might be possible, I will post back if it works or not

OK I gave up completely on using the notifier option and redid it so that when a score of either 10 20 or 30 is reached it hides everything on the screen, and displays a different background image along with a text label message and button the user has to press to continue, was alot of moving logic commands to different call procedures but it now does what I want so im gonna mark this as completed as I have found a work around for what I was trying to accomplish
Reply all
Reply to author
Forward
0 new messages