First of all i would like to tell you, i am new to blackeberry development.
Somehow i have developed an application in BB 5.0.0 and above.
I have a functionality to implement where i can download BB app (like .cod file) and upgrade it, from with in my app.
Upgraded app will be kept on my company server and when i call my sever and find upgraded version, i can upgrade it programmatically.
I referred this link and originally found references here
Not able to get this task done with above solution. I think above URL solution needs BB AppWorld as a mediator or upgraded version to be kept on BB App server.
Please let me know whether i can upgrade my BB app by downloading and replacing from within it by executing some code without keeping it on BB App world and if yes then whether i can achieve this with above referred link.
This is possible in Android and J2ME and not possible in iOS, but don't know about Blackberry.
Edit:
I implemented installer app code given in official blackberry developer site and getting following exception. Check my logs.
{"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
Update
Installer code i kept for my purpose in my app:
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));
I am getting result = 10 which is CodeModuleManager.CMM_HANDLE_INVALID, now due to this next condition throws exception and so on, now i have found out that file is actually getting downloaded but when it tries to save, int result = CodeModuleManager.saveNewModule(moduleHandles, true);
at this line i am getting CMM_HANDLE_INVALID. If anyone knows the issue please let me know.
Thanks in advance.