Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
ianstrain
Posts: 62
Registered: ‎07-15-2008
My Device: Not Specified
Accepted Solution

SystemListener powerOff()

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.

 

New Developer
Blizzz
Posts: 10
Registered: ‎07-17-2008
My Device: Not Specified

Re: SystemListener powerOff()

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

 

 

Developer
ianstrain
Posts: 62
Registered: ‎07-15-2008
My Device: Not Specified

Re: SystemListener powerOff()

Yes it is a pure MIDP application due to portablity requirements.
Developer
ianstrain
Posts: 62
Registered: ‎07-15-2008
My Device: Not Specified

Re: SystemListener powerOff()

Does anyone have a way of detecting the device being turned off or even the red button being pressed when your application is a MIDlet
Developer
ianstrain
Posts: 62
Registered: ‎07-15-2008
My Device: Not Specified

Re: SystemListener powerOff()

solved it, in my midlet I use

Application.getApplication().addSystemListener( this );

 

works a charm!