| Reply | « Previous Thread | Next Thread » |
|
Hi everyone,
I'm currently developing a midlet which is designed to run on N95. It's a location based midlet and I'd like it to run in background. My app is launched via pushregistry (on the reception of a sms) and should next be placed in background and continue to execute. According to what I've read it may be possible to do this (on S60 devices) using display.setCurrent(null); but it doesn't seems to work when trying to do it on the real device (N95). Has anyone already managed to run a middlet in background on a N95 ? If so how has he done it ? |
|
There is no real method to push your MIDlet to the background from the MIDlet itself, but it can continue executing in the background if the system pushes it there (incoming call for example) or the user opens another application on top of it. At this point the system notifies the MIDlet calling the hideNotify method in Canvas class. If you are using high-level UI screens (like Forms), you can check if the MIDlet is in the foreground/background by calling isShown method every now and then.
Hartti |
|
Hi,
First of all thank you for your rapid answer. This forum is the best J2ME forum I could find and everybody is very kind ;) (I'll stop here or else I'll ask you to marry me lol). I know there is no "real" method for putting a midlet in background (will be implemented in MIDP 3.0) but I saw some people arguing that on S60 devices, the display.setCurrent(null) is intercepted by the phone which decides to put the midlet in background. On my N95 it seems this "trick" doesn't work and I'd like to know if someone managed to do it with the same phone. Of course the "auto-hiding" when receiving a call is a good starting point but I'd like the midlet to be sent background as the midlet is launched. Then I don't need to check anymore if it's background or not (don't use the isShown method). |
|
Hi,
There is an example of minimize (put the app in background) working on a n95, Code:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloMIDlet extends MIDlet implements CommandListener {
private Command exitCommand;
private Command minimize;
private Display display;
private TextBox t = null;
public HelloMIDlet() {
display = Display.getDisplay(this);
minimize = new Command("Minimize", Command.ITEM, 1);
exitCommand = new Command("Exit", Command.EXIT, 2);
t = new TextBox("Hello MIDlet","Test string",256, 0);
t.addCommand(minimize);
t.addCommand(exitCommand);
t.setCommandListener(this);
}
public void startApp(){
display.setCurrent(t);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional){
}
public void commandAction(Command c, Displayable s){
if (c == minimize){
display.setCurrent(null);
}else if(c == exitCommand){
destroyApp(false);
notifyDestroyed();
}
}
}
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| How to run midlet in background | deveshwani | Digital Rights Management & Content Downloading | 2 | 2009-05-20 07:51 |
| S40 Background Midlet | Razr | Mobile Java General | 1 | 2006-12-26 18:18 |
| Keep script running in the background | bercobeute | Python | 2 | 2005-03-11 10:00 |
| Crash when running midlet from Sun Java Studio mobility | mgyorffy | Mobile Java Tools & SDKs | 0 | 2005-02-01 23:26 |
| 'Running in background' 6310 emulator. | martinchisnall | Mobile Java General | 0 | 2004-02-11 21:54 |