首先我想告訴你,我是blackeberry開發的新手。在黑莓中升級自己的應用程序
不知何故,我在BB 5.0.0及以上版本中開發了一個應用程序。
我要實現在那裏我可以在我的應用程序下載BB應用(如.cod文件)和升級,從一個功能。
升級後的應用程序將保持我公司的服務器上,當我把我的服務器,找到升級版,我可以通過編程方式升級。
沒能得到這個任務與上述溶液中進行。 我覺得上面的URL解決方案需要BB AppWorld作爲中介或升級版本才能保留在BB App服務器上。
請讓我知道我是否可以通過下載並通過執行一些代碼,而無需將其保持在BB應用程序從世界中它更換升級我的BB應用程序,如果是,那麼是否我可以達到以上這個被稱爲鏈接。
這是可能的Android和J2ME以及無法在iOS中,但不知道黑莓。
編輯:
我實現了官方黑莓開發者網站並獲得以下異常給安裝的應用程序代碼。檢查我的日誌。
{"FileSize":2338776,"FileName":"MyApp_3.0.1.cod","LatestBuild":"2","LatestVersion":"3.0.1","DownloadURL":"http://myserver.link/uploads/116/MyApp_3.0.1.cod"}
0:08:38.025: MyApp is being upgraded to version 3.0.1
0:10:31.509: [AppWorld] - 01/23 11:38:00 INFO Updater run() Update check at: Thu Jan 23 11:38:00 GMT 2014
0:10:31.511: [AppWorld] - 01/23 11:38:00 DEBUG AbstractDatabase readDatabase()
0:10:31.513: [AppWorld] - 01/23 11:38:00 DEBUG Updater run() Updater Content Installs 5
0:10:31.516: [AppWorld] - 01/23 11:38:00 DEBUG Connecting to: 80bba47723dae059a32abfff7844cea89fbb7bc1e90e3ed8159e626b8427aeac825047d8b3dbc418dbf3b04b6dfd17a6f063f3d7cd6a0ed860be0c9f81cf58f488916d58a1d5b3fc52f1806693b9f8179b9fc9de5643c62f2bf92f4945716455af200982fa
0:10:31.518: 1618056b5bddb91f830ae1d11076db1ec2adb6
0:10:31.519: [AppWorld] - 01/23 11:38:00 DEBUG Connection Method: DEVICE
0:10:31.940: [AppWorld] - 01/23 11:38:00 INFO AppStoreConnection: HTTP 200 , Content-Length: 2497
0:10:31.942: [AppWorld] - 01/23 11:38:00 INFO Appworld server reporting minimum version: 4.0.0.55 our local version is: 2.1.4.13
0:10:31.944: [AppWorld] - 01/23 11:38:00 22 ERROR An error has occur while updating. Updater load() id1 null
0:10:31.948: VM:PISVt=0,h=4d1e,id=d15a33128dfbb5d9
0:10:31.949: VM:LNTDa=commit,t=1,p=net_rim_bb_appworld_updater,h=135
0:10:31.951: [AppWorld] - 01/23 11:38:00 22 ERROR An error has occur while updating. null
0:10:31.954: VM:PISVt=0,h=4d1e,id=d15a33128dfbb5d9
0:10:31.956: VM:LNTDa=commit,t=1,p=net_rim_bb_appworld_updater,h=135
0:10:31.957: [AppWorld] - 01/23 11:38:00 INFO Updater rescheduleUpdateTime() Attempting to schedule Next Update at Thu Jan 23 12:08:00 GMT 2014
0:10:31.959: AM: App net_rim_bb_appworld_updater is trying to schedule for time: 1390478880504
0:10:31.960: AM: Scheduled net_rim_bb_appworld_updater for 1390478880000
0:10:31.962: [AppWorld] - 01/23 11:38:00 INFO AppWorld Updater Rescheduled @ Thu Jan 23 12:08:00 GMT 2014
0:10:31.971: Process net_rim_bb_appworld_updater(303) cleanup started
0:10:31.972: Process net_rim_bb_appworld_updater(303) cleanup done
0:10:38.055: Exception: java.io.InterruptedIOException: Local connection timed out after ~ 120000 downloading URL: http://myserver.link/uploads/116/MyApp_3.0.1.cod
0:10:38.059: FD Back On
0:10:38.061: Exception during install of MyApp java.lang.NullPointerException
0:10:38.064: MyApp 3.0.1 failed to upgrade.
0:10:38.117: FocusHistory: Focus gained; App net_rim_services_impl; Component net.rim.device.api.ui.component.ButtonField
更新
安裝程序代碼,我在我的應用程序保存我的目的:
CodeModuleGroup cmGroup = new CodeModuleGroup(appInfo.getModuleGroupName());
cmGroup.setFriendlyName(appInfo.getModuleGroupFriendlyName());
cmGroup.setVersion(appInfo.getVersion());
cmGroup.setVendor(appInfo.getVendor());
//Download and save all of the cod files.
//for(int count = 0; count < numOfCods; ++count)
//{
byte[] codData = downloadFile(appInfo.getDescriptorURL());
// if (codData != null)
// {
//Create the new cod file.
moduleHandles = CodeModuleManager.createNewModule(codData.length, codData, codData.length);
//Save the module
int result = CodeModuleManager.saveNewModule(moduleHandles, true);
log("Result code :"+result);
//Ensure that the cod file was saved.
if (result != CodeModuleManager.CMM_OK && result != CodeModuleManager.CMM_OK_MODULE_OVERWRITTEN)
{
//The cod file was not saved.
throw new Exception("Failed to save cod."+result);
}
//Add the CodeModule to the CodeModuleGroup.
cmGroup.addModule(CodeModuleManager.getModuleName(moduleHandles));
我得到的結果= 10是CodeModuleManager.CMM_HANDLE_INVALID,由於現在這一個條件拋出異常等,現在我已經發現該文件實際上正在下載,但當它試圖保存,int result = CodeModuleManager.saveNewModule(moduleHandles, true);
在這一行我越來越CMM_HANDLE_INVALID。如果有人知道這個問題,請讓我知道。
在此先感謝。
您能否提供參考(鏈接)到您正在實施的安裝程序代碼? –
我使用官方知識庫文章中給出的代碼,有一個名爲Installer.zip的附件,http://supportforums.blackberry.com/t5/Java-Development/Programmatically-install-and-upgrade-applications/ta-p/443008 – Ankit
那麼下次只需將來自您的應用程序或與您的應用程序相關的日誌消息。你甚至不必發佈這個日誌 - 一個相關的異常是我們需要的。 –