Question

I want to minimize my app and after the timer end get it back.

I use code below.

To minimize application use following line of code:

   Display.getDisplay (MIDLET_CLASS_NAME).setCurrent (null);

To get the screen back use the following:

   Display.getDisplay (MIDLET_CLASS_NAME).setCurrent (myCanvas);

But when phone display is dismissed and going to clock mode my midlet display isn't shown until press any button.

any idea?

Was it helpful?

Solution

From your question it sounds that you expect setCurrent to somehow "force" device to immediately display your screen or maybe return only after screen gets visible.

This is not so, as clearly explained in the API documentation for Display.setCurrent:

Requests that a different Displayable object be made visible on the display. The change will typically not take effect immediately. It may be delayed so that it occurs between event delivery method calls, although it is not guaranteed to occur before the next event delivery method is called. The setCurrent method returns immediately, without waiting for the change to take place...

...if the application is in the background, passing a non-null reference to setCurrent may be interpreted by the application management software as a request that the application is requesting to be brought to the foreground... These are only requests, and there is no requirement that the application management software comply with these requests in a timely fashion if at all...


Consider redesigning your MIDlet to adjust to specified behavior.

If myCanvas is an instance of Canvas, one can use showNotify() events.

For a generic Displayable screen isShown() method checks if the it is actually visible on the display.

Sometimes it could even make sense to let user explicitly confirm return from background, like

display.setCurrent(new Alert("back to foreground", "dismiss to continue...",
        null, AlertType.INFO), myCanvas);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top