How Do I Minimize a J2ME App?
Asked Answered
B

5

6

I need my J2ME app to run in the background and still allow the user to use his mobile without problem. the app still needs to process some events in the background.

I would also like to allow the user to stop the app if he wants to.

How can I accomplish this?

Belita answered 5/7, 2009 at 16:34 Comment(0)
I
2

Running a midlet in the background but still processing is not specified in the j2me standard i think. Normaly at the moment your midlet is moved to background the paused method should be called.

But not every vendor implements it that way. Symbian keeps your program running as if there was no change when minimized. At least on the N80 and N90.

Iseult answered 5/7, 2009 at 17:9 Comment(0)
C
2

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 foreground :-

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

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

Chinkapin answered 8/2, 2013 at 7:1 Comment(0)
F
1

This is not always supported, but on the handsets that do, the command is:

Display.getDisplay(theMidlet).setCurrent(null);
Freehold answered 6/7, 2009 at 8:28 Comment(0)
M
0

If you app is in background then it doesn't receive any events. So I don't know how it can process any event in the background. If its a preload J2ME app then you can work with the handset manufacturer and obtain certain jad attributes to put your midlet in background. You can thus not allow the user to exit the app. You may want to think this use case through.

On the other hand you can do all these in Blackberry apps.

Moran answered 5/7, 2009 at 22:32 Comment(3)
i mean when my app is in the background, it will still occasionally send sms to a predefined number in maybe a separate thread. is that possible ?Belita
You may not be able to do that. However, you can keep a HTTP connection open, send a message to a web page that sends the sms to that number.Moran
Hey @Belita you can do this. But this is possible in those device which support multitasking like as Nokia S60.Repression
E
-2
MIDlet.notifyPaused()
Electrolysis answered 5/7, 2009 at 16:38 Comment(3)
I need the midlet to continue running in the background (interface not showing, minimized like in the case of desktop app). it is my understanding that using the method notifyPaused() will momentarily pause the execution of the midlet.Belita
But what if your phone does not call this 'notifyPaused()' callback method? Instead, your phone may be very low on resources and decides to close your J2ME program all togetherFourth
This tells the midlet to pause not detect pause methods.Trix

© 2022 - 2024 — McMap. All rights reserved.