简体   繁体   English

如何在后台运行J2ME应用程序?

[英]How to make a J2ME application run in Background?

I have a written a J2ME application which uses Bluetooth and search a file within the peer mobile and download it. 我有一个J2ME应用程序,它使用蓝牙并在对等移动设备中搜索文件并下载它。 I would like to make my application run in background , whenever I get a call , or message and later resume after few seconds , Has anybody worked on this please share your experience . 我希望让我的应用程序在后台运行,无论何时我接到电话,或者消息以及稍后几秒后恢复,有没有人就此工作请分享您的经验。 Is there any way to run a Midlet in background ? 有没有办法在后台运行Midlet?

to set a j2me app to the background use the following in your midlet class: 要将j2me应用程序设置为后台,请在midlet类中使用以下内容:

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

to get the screen back use the following: 要获得屏幕,请使用以下内容:

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

Where myCanvas is your canvas instantiation myCanvas是你的画布实例化

R [R

ps You can still use a thread or timer to do things in the background while your midlet is hidden. ps当您的midlet被隐藏时,您仍然可以使用线程或计时器在后台执行操作。

ps2: this does not work on all models. ps2:这不适用于所有型号。 (Works on Nokia s60, SonyEricsson, but not on Nokia s40, Samsung and some others. (适用于诺基亚s60,索尼爱立信,但不适用于诺基亚s40,三星和其他一些产品。

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. 因此,与低成本设备相比,更昂贵的PDA型设备更可能支持后台执行。 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). 但请注意,它不支持所有设备。(适用于诺基亚s60,索尼爱立信,但不适用于诺基亚s40,三星和其他一些设备)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM