How to make a J2ME application run in Background?

痞子三分冷 提交于 2019-12-03 03:16:50

to set a j2me app to the background use the following in your midlet class:

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

to get the screen back use the following:

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

Where myCanvas is your canvas instantiation

R

p.s. You can still use a thread or timer to do things in the background while your midlet is hidden.

p.s.2: this does not work on all models. (Works on Nokia s60, SonyEricsson, but not on Nokia s40, Samsung and some others.

A device's ability to run an application in the background depends on its ability to multitask. Therefore, more expensive, PDA-type devices are more likely to support background execution than lower-cost devices. For in background :-

private Display display = Display.getDisplay(this);
private Displayable previousDisplayable;

public void toBack() {
previousDisplayable = display.getCurrent();
display.setCurrent(null);
}

And to come in Fore ground :-

public void toFront() {
display.setCurrent(previousDisplayable);
}

But be aware that it not supports every device.(Works on Nokia s60, SonyEricsson, but not on Nokia s40, Samsung and some others).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!