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
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

device not getting reboot programatically...

In Os 7.1 the device is not getting reboot programatically..............................

It does with OS 6....

 

can any tell where is the problem...

Thanks in advance....

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: device not getting reboot programatically...

what is the code you use to reboot the device?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

Re: device not getting reboot programatically...


public boolean restartMobile() {
try {

String codName = "com_sample_Restart" + "" + ".cod";

String codGroupName = "RestartApp";// + taskCount;

byte[] cod = IOUtilities.streamToBytes(getClass()
.getResourceAsStream("com_sample_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("com_sample_Restart");
cmGroup.store();

int[] hand = CodeModuleManager.getModuleHandles();
int handleForDelete = 0;
for (int i = 0; i < hand.length; i++) {
if (CodeModuleManager.getModuleName(hand[i]).equals(
"com_sample_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();
// return true;
}


// autoRestart();
doRestart();

} catch (Throwable t) {
t.printStackTrace();
System.out.println("Error attempting restart: " + t.toString());
}
return false;
}


public void doRestart()
{
try{
//if you want to automate the reboot.
EventInjector.TrackwheelEvent moveEvent = new EventInjector.TrackwheelEvent( EventInjector.TrackwheelEvent.THUMB_ROLL_UP, 1, 1 );
EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(
KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_ENTER , 0, 100);
EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(
KeyCodeEvent.KEY_UP, (char) Keypad.KEY_ENTER, 0, 100);

try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
EventInjector.invokeEvent(moveEvent);
EventInjector.invokeEvent(pressEndKey);
EventInjector.invokeEvent(releaseEndKey);
Status.show("device is restarting");
}catch(Exception ex){}
}

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: device not getting reboot programatically...

more as a sidenote: if you run Thread.sleep on the main thread you block the whole event processing of your app. use a separate thread, or, for something simple like this, a timertask.

i would suggest that you modularize your issue, check if the module replacement still triggers the reboot request, then check if your event injection is working as intended.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

Re: device not getting reboot programatically...

new Thread()
{
public void run()
{
restartMobile();
}
}.start();

 

yes i have ran that as a seperate thread...

Developer
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

Re: device not getting reboot programatically...

Does any one has reply to that answer.............................

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: device not getting reboot programatically...

I was waiting to see what happened as a result of you doing the investigation Simon suggested. 

Developer
Posts: 235
Registered: ‎11-12-2008
My Device: Not Specified

Re: device not getting reboot programatically...

do u check with this code in OS 7 whether it is reboot or not....

OS 6 is rebooting nicely..no problem in that...but OS7 is not reboot the device...

 

Please give me a soultion of this if you have...It's required urgently..

Thanks in adance...

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: device not getting reboot programatically...

did you try the parts of your code separately?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: device not getting reboot programatically...

Can you do the investigation Simon suggested?