Question

According to the documentation, Display.setCurrent doesn't work if the current displayable is an alert. This is a problem as I would like to pop up another alert when the user selects a command. Does anyone know how to work around this so that we can go from one alert to another? I am using CLDC 1.0 and MIDP 2.0.

Additional Information

The spec does allow us to edit an alert while it is on screen, but some Nokia phones don't handle it well at all. So I am now trying to go from the alert to a blank canvas, then back to the alert. Of course I don't want the user to interact with the previous canvas, so it seems that I am forced to create a new blank canvas. As a sidenote, this has the slight disadvantage of looking worse on phones which still have the previous screen when an alert is shown.

The bigger problem is how to transition from the blank canvas back to an alert once the canvas is loaded. Testing on the Motorola emulator revealed that showNotify is not called after returning from an alert to the previous screen. I guess I could create the next alert in the paint method, but this seems like a ugly hack.

Was it helpful?

Solution 2

I couldn't find a way around this, so I just used the paint hack.

public class AlertPage extends Canvas{
    MIDlet midlet;
    Alert alert;

    private AlertPage(MIDlet midlet){
        this.midlet=midlet;
    }

    protected void paint(Graphics arg0){
        //Yep, this is a hack, but showNotify doesn't seem to work well for Motorola
        if(alert!=null){
            Display d=Display.getDisplay(midlet);
            d.setCurrent(alert);
            alert=null;
        }
    }

    public static void showAlert(MIDlet m, Alert a){
        AlertPage page=new AlertPage(m);
        Display d=Display.getDisplay(m);
        page.alert=a;
        d.setCurrent(page);
    }
}

OTHER TIPS

OK, so your problem is that you can't set it up to do:

Display.setCurrent(alert1, alert2);

and

Display.setCurrent(alert2);

is also not possible if the current Displayable is already alert1.

So how about put an intermediate Displayable item that is blank and that immediately changes to the next alert? Assuming the current Displayable is alert1, like this in your alert1's command block:

Display.setCurrent(blankForm);
Display.setCurrent(alert2);

That should work assuming you are not using the default 'Dismiss' command. So basically it goes from alert1->(blankForm->alert2).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top