×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    17

    Alert with Gauge does not display

    I have the following piece of test code:

    public void createTestData(int size)
    {
    try {
    Alert alert = new Alert(null, "Creating test data...", null, AlertType.INFO);
    Gauge gauge = new Gauge(null, false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING);
    alert.setIndicator(gauge);
    alert.setTimeout(Alert.FOREVER);
    getMasterController().display(alert);

    DataFactory.createAndSaveCustomerDOs(size, new int[] { 1, 1, 1, 1, 0 });

    alert = new Alert(null, "Test data created", null, AlertType.CONFIRMATION);
    getMasterController().display(alert, homeScreen);

    } catch (SQLException e) {
    getMasterController().handleException(e);
    }
    }

    The first alert DOES NOT display. The test data gets created, and then the second alert DOES display.

    The platform is Series 40 6th edition. The same behavior is observed on a Nokia 6288.

    Thanks in advance for your help.

  2. #2
    Super Contributor
    Join Date
    Mar 2005
    Location
    Paris
    Posts
    814

    Re: Alert with Gauge does not display

    your first alert is immediatly replaced by the second one because setCurrent is not a blocking method.you need to make sure the first alert was acknoledged before you can display a second one.

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    17

    Re: Alert with Gauge does not display

    I understand your point, but DataFactory.createAndSaveCustomerDOs(size, new int[] { 1, 1, 1, 1, 0 }); is slow - it varies from a couple of seconds to 60 or more depending on the size parameter. Furthermore, I have stepped through and paused on this line with Eclipse debugger yet there was still no alert displayed.

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,085

    Re: Alert with Gauge does not display

    try this:

    Comment out - the line " // DataFactory.createAndSaveCustomerDOs(size, new int[] { 1, 1, 1, 1, 0 });"

    put this.sleep(5000) and see if you get the 1st alert.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  5. #5
    Registered User
    Join Date
    Jan 2011
    Posts
    17

    Angry Re: Alert with Gauge does not display

    I added Thread.sleep(5000); but it makes no difference.

    Whilst I have found other examples like this on the net, I thought that it may be the combination of the settings: Alert AlertType.INFO, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING, setIndicator().

    So I tried the following but it still makes no difference:
    Alert alert = new Alert(null, "Creating test data...", null, AlertType.CONFIRMATION);
    Gauge gauge = new Gauge(null, false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING);
    alert.setIndicator(gauge);
    alert.addCommand(commands.getOk());
    alert.setTimeout(1000 * 3600); // 1 hour
    alert.setCommandListener(new CommandListener()
    {
    public void commandAction(javax.microedition.lcdui.Command command, Displayable displayable)
    {
    // do nothing
    }
    });

    I have also tried other combinations, such as just removing the gauge.

  6. #6
    Super Contributor
    Join Date
    Mar 2005
    Location
    Paris
    Posts
    814

    Re: Alert with Gauge does not display

    The Alert is displayed whenever the system thread has the time to do it. A thread.yield() before you call your long, blocking method may help that.

  7. #7
    Registered User
    Join Date
    Jan 2011
    Posts
    17

    Red face Re: Alert with Gauge does not display

    Thread.yield() didn't work but
    Quote Originally Posted by njzk2 View Post
    The Alert is displayed whenever the system thread has the time to do it.
    was absolutely correct.

    The solution is to run the slow method as a thread, thus giving the system the time to display the alert:

    public void createTestData(int size)
    {
    Alert alert = new Alert(null, "Creating test data...", null, AlertType.INFO);
    Gauge gauge = new Gauge(null, false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING);
    alert.setIndicator(gauge);
    alert.setTimeout(Alert.FOREVER);
    getMasterController().display(alert);

    final int s = size;
    Runnable r = new Runnable()
    {
    public void run()
    {
    try {
    DataFactory.createAndSaveCustomerDOs(s, new int[] { 1, 1, 1, 1, 0 });
    Alert alert = new Alert(null, "Test data created", null, AlertType.CONFIRMATION);
    getMasterController().display(alert, homeScreen);
    } catch (SQLException e) {
    getMasterController().handleException(e);
    }
    }
    };
    Thread t = new Thread(r);
    t.start();

    }

    Thanks ever so much for your response!

Similar Threads

  1. What is The Alert Gauge??
    By buffon2009 in forum Mobile Java General
    Replies: 1
    Last Post: 2011-01-19, 23:02
  2. Could not display a runnable Alert after another displayable
    By yasirg in forum Mobile Java General
    Replies: 1
    Last Post: 2010-05-02, 13:49
  3. Not able to set Gauge on Alert
    By sandeep.gadhvi1185 in forum Mobile Java General
    Replies: 2
    Last Post: 2008-07-22, 14:30
  4. Proble with a gauge into an Alert
    By zidia in forum Mobile Java General
    Replies: 1
    Last Post: 2007-11-19, 15:23
  5. XHTML page does not display (N3650 with sw2.48)
    By engwah00 in forum Browsing and Mark-ups
    Replies: 1
    Last Post: 2003-04-01, 04:15

Posting Permissions

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