Display “Warning” and “Alert” box messages in App Inventor apps

Whether you use Windows, Linux or Mac OS X applications, when the program needs to alert the user (you!) to an issue, the program displays a pop up dialog box with a warning or error message. You can easily create similar warning messages in App Inventor, as shown in this example screen:

Screenshot_2014-09-08-14-05-48

To create a pop up warning dialog, use the Notifier control that appears in the Designer’s Palette:

NotifyPalette

Drag the Notifier icon into the app user interface design – the Notifier is used as a non-visible component, just below the user interface:

NotifyDesignerView

Switch to the Blocks view, click on the Notifier1 block to view the available methods. A partial list of methods is shown here – the item circled in red is the one we will use in this example:

NotifierMethods

In response to an on screen button press (btnNotifyUser’s Click event), the app displays the dialog message:

 

NotifyBlockCodeThis block can be inserted anywhere a processing block is allowed such as the result of an if-then-else conditional block. You can also change the text or background color of the app to something more interesting than the “black and white” default colors shown in this example.

Notifier provides a quick and easy way to display short alert messages to the user of the app.

 

Advertisements

17 thoughts on “Display “Warning” and “Alert” box messages in App Inventor apps

  1. Very nice article. I need to offer a solution to test similar application which works on Bluetooth and via mobile the server-blutooth is configured manually.
    – how can we test such bluetooth applications,
    – any way to automate this setup on PC? testing this automatically. – – I’m student so please describe in detail.
    thanks.

    Like

    • Alka, at this time, App Inventor lacks automated testing tools. It might be possible, I suppose, to run an app in the emulator and use an automated test tool that can then run an application automatically (say on Windows). But I have no idea if this would actually work. It is just an idea. And I have not looked in to trying to use Bluetooth feature in the emulator; Bluetooth might not work in the emulator. These are just some ideas and thoughts for further testing – for now, I am not aware of an existing automated test solution.

      Like

    • Here is an answer to what I think you are asking:

      In the Blocks Editor, click on the button component located in the left hand column below “Screen1”. You will see a pop up menu of choices.

      Click on and drag the item labeled When buttonname.Click over to the Blocks Editor.

      Whenever the user presses the button, this “event” will be run. Put code inside this event handler to do what ever you want it to do.

      Let’s say you have two buttons: Button1 and Button2. You will add two event handler blocks, like

      When Button1.Click do

      and

      When Button2.Click do

      Put the code to do whatever you want them to do inside those event handler blocks.

      Ed

      Like

    • Ok – now I see that this is about the Notifier? Sorry, I should have caught that.

      Add a When Notifier1.AfterChoosing event handler to your program. This eventhandler has a parameter named “choice”.

      Use “get choice” (just like a variable) to get the value of “choice“. The value will be exactly equal to the text of the button.

      If button 1 is “Okay” and button 2 is “Cancel”, when you press “Cancel”, the value of choice in the AfterChoosing eventhandler will be “Cancel”. Use an if-then comparison statement to determine which button was pressed and decide what action will be taken.

      Does that help?

      Ed

      Like

      • I’m trying to do this: [When “buttonA” click do, call “notif1″ showChooseDialog”, message”?”, title “?”, button1Text”No”, button2Text”Yes”, cancelable”false”.] Then I want to call a number when the “yes” is selected, and close the window popup if the “No” is selected. But how?????? I tried to pick a [When notif1 AfterChoosing, choice do
        (1):call “XXX” MakePhoneCall
        (2): set choice to “Yes” then call “XXX” Make PhoneCall
        (3): and many other things but didn’t work….

        ((The (x): are the combinations I’we tried ))

        I’ve tried everything you said but it doesn’t work….
        Please help me!!

        Like

  2. Hi.Im a newbie..Im trying to do a messaging app for the past 1 week..but it shows “generic failure message not sent”..can u plz help me to sort this out??..I hav seen many sites and forums but the answer didnt do wel on mine..

    Like

    • Hello,
      I do not understand what you are trying to do – you are calling the Notifier and passing to it the text messages you want to display? And then it gives you an error “generic failure, no message sent”? That seems like an odd error.

      Ed

      Like

  3. Pingback: Part 1: Basic Bluetooth communications using App Inventor | App Inventor 2 – Learn to Code!

  4. hello
    thanks for this helpful tutorial. i need some help if it is possible and here is my question: iam trying to develop a small app by using mit appinventor but i cant find out how to do a popup list like a menu or an options list. so would you help me please to figure out how to do it because i’ve been trying different ways but it did not work.like this one on the link http://i.stack.imgur.com/uJGlW.png. thanks

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s