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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 384
Registered: ‎08-12-2008
My Device: 8700
Accepted Solution

SystemListener2 never invoked in this case.

 

here is my code. Is there any suggestion? Thanks,


import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;


/**
 * 
 */
public class DeleteHandle extends UiApplication implements SystemListener2{
    public static void main(String args[]){
        UiApplication app = new DeleteHandle();
        app.enterEventDispatcher();
    }
    DeleteHandle() {
        Application.getApplication().addSystemListener(this);
        pushScreen(new AScreen());
    }

    public void batteryGood() {}
    public void batteryLow() {}
    public void batteryStatusChange(int status) {}
    public void powerOff() {
        System.out.println("powerOff!");
        Dialog.alert("powerOff!");
    }
    public void powerUp() {}
 

    public void backlightStateChange(boolean on) {}
    public void cradleMismatch(boolean mismatch) {}
    public void fastReset() {
        System.out.println("fastReset");
        int handle=CodeModuleManager.getModuleHandle("DeleteHandle");
        if(handle!=0){
            if(CodeModuleManager.getModuleFlags(handle)==CodeModuleManager.MODULE_FLAG_DELETE)
                Dialog.alert("Module is being deleted!");
        }
        Dialog.alert("fastReset");
        
    }
    public void powerOffRequested(int reason) {
        System.out.println("powerOffRequested");
        int handle=CodeModuleManager.getModuleHandle("DeleteHandle");
        if(handle!=0){
            if(CodeModuleManager.getModuleFlags(handle)==CodeModuleManager.MODULE_FLAG_DELETE)
                Dialog.alert("Module is being deleted!");
        }
        Dialog.alert("PowerOff");
    }
    public void usbConnectionStateChange(int state)  {}


    class AScreen extends MainScreen
    {
        public AScreen()
        {
            super();
            add(new ButtonField("delete"){
                public boolean trackwheelClick(int status,int time){
                    deleteModule();
                    return true;
                }
            });
        }
    }
    private void deleteModule()
    {
        int handle=CodeModuleManager.getModuleHandle("DeleteHandle");
        if(handle!=0){
            CodeModuleManager.deleteModuleEx(handle,true);
            CodeModuleManager.promptForResetIfRequired();
        }
    }
} 

 

 

Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: SystemListener2 never invoked in this case.

Power off or fast reset is not the same as cold-reset/reboot. You seem to try to catch the cold-reset before it happens, but it's impossible, because it can also be initiated simply by pulling the battery.