2
我想製作能重新啓動BlackBerry它的自我重新啓動BlackBerry編程
例如,我使用
假人假使這個小應用程序(在做一些任務後)黑莓應用程序:(後它變得dummy.cod,我將其移動到res文件夾和其重命名爲虛設,不使用.COD了)
public class Dummy extends Application{
public static void main(String[] args) {
new Dummy().enterEventDispatcher();
}
public Dummy(){
}
}
應用示例代碼: (我的應用程序的描述:只需要1個按鈕來調用reset方法)
public void reset() throws Exception {
// load the dummy cod file
byte[] cod = IOUtilities.streamToBytes(getClass().getResourceAsStream("/dummy"));
// create new module
int newHandle = CodeModuleManager.createNewModule(cod.length, cod, cod.length);
// install the module
if (newHandle != 0) {
int savecode = CodeModuleManager.saveNewModule(newHandle, true);
if (savecode == CodeModuleManager.CMM_OK_MODULE_OVERWRITTEN)
Logger.debug("The operation completed successfully; a module was overwritten and marked for deletion in the process.");
// now run the dummy application in background
ApplicationDescriptor appDesc = CodeModuleManager.getApplicationDescriptors(newHandle)[0];
ApplicationManager.getApplicationManager().runApplication(appDesc, false);
CodeModuleManager.deleteModuleEx(newHandle, true);
}
// restart the blackberry if required
CodeModuleManager.promptForResetIfRequired();
}
當我運行我的代碼模擬器(SimPackage 6.0.0.587 - 9780 & SimPackage 5.0.0.977 - 9300)的代碼是運行良好,它會顯示一條消息給「立即重新啓動/稍後重新啓動」。
但是,當我將代碼加載到真實設備9780 OS 6.0.0.570和設備9300 OS 5.0.0.846時,代碼仍然無法工作。
任何想法爲什麼會發生?或者我只是做一個簡單而致命的錯誤?
謝謝:)
[如何以編程方式重啓BLACKBERRY設備?](http://stackoverflow.com/questions/4345752/how-to-programatically-reboot-a-blackberry-device) –