Skip to main content

Can I unse pauseApp() inside StateMachine ??

3 replies [Last post]
68060
Offline
Joined: 2011-08-29
Points: 0

Id like my app to stay alive when user switchs to another app, or indeed if my user explicity hits my "minimise" button, I guess something like:

public void pauseApp() {
javax.microedition.lcdui.Display.getDisplay(this).setCurrent(null);
}

would do the trick to keep it alive when they go to another task - can I put this in StateMachine and itll work? I mean I cant actually see what initially extends midlet, so im not sure if this will work?

thanks.

Gaz.

EDIT: ok i see MainMIDlet class and these methods work in there- but how do I "get" this midlet from StateMachine? it seemingly wont import... id like to explicitly set midlet to go to background from statemachine but cant access it

EDIT2: OK i see it.. Display.getInstance().minimizeApplication();

awesome ;)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07
Points: 0

The reason for the separation is increased portability since pause doesn't exist on RIM/Android/SE/desktop or is implemented differently. So the main project should be portable to all these platforms while the sub project should be platform specific. minimizeApplication() should be portable where supported and do nothing where unsupported.

68060
Offline
Joined: 2011-08-29
Points: 0

thanks - so in pauseapp I can do:

Display.getInstance().minimizeApplication(); //send app to background

and in startApp I do:

Display.getInstance().restoreMinimizedApplication(); // bring app back to life if its minimised

and that is the best way to support it, if the handset supports it? am I right?

thanks,

Gaz.

vprise
Offline
Joined: 2003-11-07
Points: 0

Assuming firstTime is false yep that's probably the best way.