×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    3

    Alert with both Yes & No Commands

    Hi all,

    I'm writing midlets for Nokia N70 (Serie 60 with OS 8.1a) and I've installed the SDK "Series 60 2nd Edition SDK for Symbian OS, Supporting Feature Pack 3, for MIDP".
    The problem is about a simple (in theory) YES/NO dialog implemented with an Alert: when the user presses 'NO' the command executed is the same as when he/she presses 'YES'.
    Here's the code:

    public class YesNoAlert extends MIDlet implements CommandListener
    {
    private Display display;
    private Command yes;
    private Command no;
    private Alert alert;
    private TextBox textBox;
    public YesNoAlert()
    {
    display = Display.getDisplay(this);
    textBox = new TextBox("HelloNokia", "Welcome to Nokia\n", 256, 0);

    alert = new Alert("Alert YES/NO", "Press YES or NO", null, AlertType.CONFIRMATION);
    yes = new Command("Yes", Command.OK, 1);
    no = new Command("No", Command.CANCEL, 1);
    alert.setTimeout(Alert.FOREVER);
    alert.addCommand(yes);
    alert.addCommand(no);

    alert.setCommandListener(this);
    }

    public void commandAction(Command command, Displayable displayable)
    {
    if (command == yes)
    textBox.setString("Pressed: YES");
    else if (command == no)
    textBox.setString("Pressed: NO");
    else
    textBox.setString("IMPOSSIBLE");
    display.setCurrent(textBox);
    }

    protected void startApp() throws MIDletStateChangeException
    {
    display.setCurrent(alert);
    }
    ...
    }


    The problem persists even if I change the no-command's 'priority' to '2' and/or 'commandType' to 'BACK'.
    Instead, changing the Alert with a TextBox it works.

    Any suggestions?

    Thanks,
    Giannandrea

  2. #2
    Registered User
    Join Date
    Apr 2004
    Posts
    12

    Re: Alert with both Yes & No Commands

    I've seen that problem too. The Alerts on N70s appear to get confused by different command types. One of the workarounds is to give both (or all) commands the type Command.SCREEN.

    -Lujo

  3. #3
    Registered User
    Join Date
    Nov 2012
    Posts
    1

    Re: Alert with both Yes & No Commands

    please try to change AlertType to null.
    alert = new Alert("Alert YES/NO", "Press YES or NO", null, null);

Similar Threads

  1. Displaying Alert in MIDP1
    By anand_amarsh in forum Mobile Java General
    Replies: 2
    Last Post: 2004-12-28, 07:08
  2. Creating an Alert without commands
    By kimtommy in forum Mobile Java General
    Replies: 0
    Last Post: 2004-10-15, 15:35
  3. 6600 & instantiating Alert dialogs from within Timer's thread context
    By random_john_doe in forum Mobile Java General
    Replies: 0
    Last Post: 2004-01-15, 17:20
  4. Displaying an Alert on a J2ME device
    By cj901 in forum Mobile Java General
    Replies: 1
    Last Post: 2003-03-25, 03:18
  5. How to send Flash & Alert SMS Using AT Commands
    By naveen_galipally in forum General Messaging
    Replies: 1
    Last Post: 2002-10-23, 11:12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×