07-30-2008 11:12 AM
JDE: 4.3.0
I am developing a MIDlet and I have implemented the SystemListener in order for me to use the powerOff method that gets called when the user powers off the device. When I run the simulator and run the MIDlet and then hold in the red button, the powerOff method is not called, neither is the powerOn() method when I press the red button again. This is also the dehaviour on the device. I have also written a test midlet but I get the same results.
import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import net.rim.device.api.system.SystemListener; public class PowerOffTest extends MIDlet implements SystemListener { Form f = new Form ("Power Off"); Display d; public PowerOffTest() { d = Display.getDisplay( this ); d.setCurrent( f ); } public void startApp() { f.append( "START APP CALLED" ); System.out.println( "START APP" ); } public void pauseApp() { f.append( "PAUSE APP CALLED" ); System.out.println( "PAUSE APP" ); } public void destroyApp(boolean unconditional) { f.append( "DESTORY APP CALLED" ); System.out.println( "DESTROY APP" ); } public void powerOff() { f.append( "POWER OFF CALLED" ); System.out.println( "POWER OFF" ); } public void powerUp() { f.append( "POWER UP CALLED" ); System.out.println( "POWER UP" ); } public void batteryLow() { } public void batteryGood() { } public void batteryStatusChange( int arg0 ) { } }
Can anyone tell me what I need to do in order for my MIDlet to detect the device being turned off.
Solved! Go to Solution.
07-30-2008 11:48 AM
Hello,
where are you actually registering for the systemlistener? You would have to register by calling addSystemListener() , which is a method of UIApplication. Is your app a pure MIDP application ?
best regards,
blizzz
07-30-2008 12:33 PM
07-30-2008 12:38 PM
07-30-2008 12:44 PM
solved it, in my midlet I use
Application.getApplication().addSystemListener( this );
works a charm!