You Are Here:

Community: Developer Discussion Boards

#1 Old Running midlet in background on N95 - 2007-08-02, 09:42

Join Date: Jun 2007
Posts: 4
flocoon
Offline
Registered User
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 ?
Reply With Quote

#2 Old Re: Running midlet in background on N95 - 2007-08-02, 20:29

Join Date: Apr 2003
Posts: 6,408
Location: USA, CA
hartti's Avatar
hartti
Offline
Nokia Expert
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
Reply With Quote

#3 Old Re: Running midlet in background on N95 - 2007-08-06, 12:09

Join Date: Jun 2007
Posts: 4
flocoon
Offline
Registered User
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).
Reply With Quote

#4 Old Re: Running midlet in background on N95 - 2007-08-14, 15:29

Join Date: Jun 2007
Posts: 1
hugares
Offline
Registered User
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();
		}
	}
}
Hugo
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia