10-19-2011 02:30 AM
Hello All,
I am trying to reboot device pragmatically. By installing and deleting new module.
Application working fine in simulator and but not in device. But it works fine on device if I attach debugger and debug application on device...
Any idea what is the problem here. I am following this Thread to reboot device.
Thanks in advance
Solved! Go to Solution.
10-19-2011 06:01 AM
The fact that it works fine on device if you attach a debugger suggests a timing thing - are you in fact trying to do something on the Event Thread which you need to do on its own Thread?
Can you log the statements that are executed in your application to some temporary log (say to the SD Card) and then track the flow of your applicaiton on device without using the debugger. Compare this flow with what you see when debugging annd that might give you a clue as to what the problem is.
10-19-2011 07:34 AM
10-19-2011 08:57 AM - edited 10-19-2011 08:57 AM
I have implemented code it in different thread from event thread. But its still not working in device.
I have also print the log and able to find following condition is not true.
if (CodeModuleManager.isResetRequired()) {
CodeModuleManager.promptForResetIfRequired(); // This is not executed when tested it in device // without debugger but its work fine when
} else {
Dialog.alert("Restart fail!");
}
Can you please suggest what is the problem here.
10-19-2011 09:44 AM
I am suspicious when you day that this is not running on the Event Thread. If it is not, then this will fail:
Dialog.alert("Restart fail!");
Other than that, sorry, no idea.
10-19-2011 09:59 AM - edited 10-19-2011 10:01 AM
Thanks for your quick reply..
Now I got improvement.
When I installed app in device, and try to reboot then its not working but after attaching the debugger and try to reboot
its working and after removing debugger its started rebooting without debugger. But first time its not working. I need to attach debugger to make it working.
I am using following code: -
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
try {
byte[] cod = IOUtilities.streamToBytes(getClass()
.getResourceAsStream("/restart.cod"));
CodeModuleGroup cmGroup = new CodeModuleGroup(
"RestartApp11");
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();
} else {
Dialog.alert("Restart fail!");
}
} catch (Throwable t) {
log("Error while restart device "
+ t.getMessage().toString());
}
}
});
10-20-2011 02:43 AM - edited 10-20-2011 02:56 AM
Hello,
I found some more information ...
When I call CodeModuleManager.deleteModuleEx() to delete a Module, the return value is CodeModuleManager.CMM_OK_MODULE_MARKED_FOR_DELETIO
What is the problem here?
10-21-2011 02:22 AM
Hello All,
Please help it still not working , i am not sure what is the problem here.
I am doing any thing wrong?