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
New Developer
jtwebfusion
Posts: 3
Registered: ‎12-04-2008
My Device: Not Specified

Re: Programmatically rebooting the device

[ Edited ]

I'm assuming that the QuickPull application is doing something else to trigger a reset, since simply calling a Device.restart(); isn't possible.

 

Can someone please tell me what are the conditions that will trigger a soft reset?

 

I've noticed that when uninstalling applications that sometimes a reset is required. I'm assuming that's because the module being uninstalled is still running.  

Message Edited by jtwebfusion on 12-12-2008 04:10 PM
Please use plain text.
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Programmatically rebooting the device

If a module is set to run when device starts (autostart in JDE project settings) then when you remove/uninstall this module - the device is going to restart. It is 100%.
Please use plain text.
Developer
Developer
bba
Posts: 266
Registered: ‎04-01-2009
My Device: Not Specified

Re: Programmatically rebooting the device

uuuh, sneaky workaround - respect!
Please use plain text.
Developer
PoojaMaheshwari
Posts: 141
Registered: ‎02-10-2010
My Device: 9500

Re: Programmatically rebooting the device

Have used CodeModuleGroup and CodeModuleManager to create a cod programmatically and uninstall after running it. The device gets rebooted 100% times on all OS versions.

Please use plain text.
Developer
ted_hulick
Posts: 229
Registered: ‎11-21-2009
My Device: Not Specified

Re: Programmatically rebooting the device

Could you post some/all of the code for the rest of us so we don't have to go thru the pain no our own...

 

Considering the interest in this subject - why doesn't BB simply expose the API to do this?

Please use plain text.
osm
Contributor
osm
Posts: 13
Registered: ‎08-16-2010
My Device: Not Specified

Re: Programmatically rebooting the device

It don't works on BB 8900 curve. Any ideas?

Please use plain text.
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Programmatically rebooting the device

The process documented should work.  Do you want to show us your code so we can check it?

Please use plain text.
osm
Contributor
osm
Posts: 13
Registered: ‎08-16-2010
My Device: Not Specified

Re: Programmatically rebooting the device

This is my dummy class:

 

import net.rim.device.api.system.Application;

public class Restart extends Application {

    public static void main(String[] args) {
        new Restart().enterEventDispatcher();
    }
    
}

and restart method:

 

    private void restart() {
        try {
            byte[] cod = IOUtilities.streamToBytes(getClass()
                    .getResourceAsStream("restart.cod"));
            // create new module
            CodeModuleGroup cmGroup = new CodeModuleGroup("RestartApp");
            int newHandle = CodeModuleManager.createNewModule(cod.length, cod,
                    cod.length);
            if (newHandle != 0) {
                int savecode = CodeModuleManager.saveNewModule(newHandle, true);
                if (savecode == CodeModuleManager.CMM_OK_MODULE_OVERWRITTEN)
                cmGroup.addModule("restart");
                cmGroup.store();
                
                int[] hand = CodeModuleManager.getModuleHandles();
                int handleForDelete = 0;
                for (int i = 0; i < hand.length; i++) {
                    if (CodeModuleManager.getModuleName(hand[i]).equals(
                            "restart")) {
                        handleForDelete = hand[i];
                        break;
                    }
                }
                ApplicationDescriptor appDesc[] = CodeModuleManager
                        .getApplicationDescriptors(handleForDelete);
                ApplicationManager.getApplicationManager().runApplication(
                        appDesc[0], false);
                CodeModuleManager.deleteModuleEx(handleForDelete, true);
            }
            if (CodeModuleManager.isResetRequired())
                CodeModuleManager.promptForResetIfRequired();
        } catch (Exception e) {
            e.printStackTrace()
        }
    }

Please use plain text.
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Programmatically rebooting the device

Code looks OK, I will have a test later.

 

Is Restart marked as a System module and auto-started?

Please use plain text.
osm
Contributor
osm
Posts: 13
Registered: ‎08-16-2010
My Device: Not Specified

Re: Programmatically rebooting the device

Not, Restart is not system module or auto-started.

 

Please use plain text.