08-05-2008 05:18 AM
Hi ,
is there any API available using which we can uninstall our application from device .
also can we upgrade our application running in background without user intervention?
Solved! Go to Solution.
08-05-2008 09:31 AM
Here is some code I use in a menu to remove an application. Hope you find it useful. In fact I've removed this menu item from the application, because it always required the device to be restarted, which meant it was actually easier for the user to delete via the Options-->Advanced Options-->Applications screen, because that automatically restarts the device. [I've yet to find a way to programatically restart the device]
private MenuItem _deleteeMenu = new MenuItem("Delete Tool", 110, 10) { // Delete us public void run() { int actionCode = Dialog.ask("Confirm Deletion", new String [] { "Continue", "Cancel" }, new int [] { 0, 1 }, 0); if ( actionCode == 0 ) { ApplicationDescriptor ad = ApplicationDescriptor.currentApplicationDescriptor
(); int moduleHandle = ad.getModuleHandle(); int rc = CodeModuleManager.deleteModuleEx(moduleHandle, true); String tellUserMessage = ""; if ( rc == CodeModuleManager.CMM_OK_MODULE_MARKED_FOR_DELETIO N ) { tellUserMessage = "Please restart the device to remove the application"; } else if ( rc == CodeModuleManager.CMM_OK ) { tellUserMessage = "Deleted"; } else { String errorString = Integer.toString(rc); switch (rc) { case CodeModuleManager.CMM_OK_MODULE_MARKED_FOR_DELETIO N: tellUserMessage = "Will be deleted on restart"; break; case CodeModuleManager.CMM_MODULE_IN_USE: case CodeModuleManager.CMM_MODULE_IN_USE_BY_PERSISTENT_ STORE: tellUserMessage = "Module In Use"; break; case CodeModuleManager.CMM_HANDLE_INVALID: tellUserMessage = "Invalid Handle"; break; case CodeModuleManager.CMM_MODULE_REQUIRED: tellUserMessage = "Module Required"; break; default: tellUserMessage = Integer.toString(rc); break; } tellUserMessage = "Error Deleting Module: " + tellUserMessage; } Dialog.alert(tellUserMessage); } } };
Regarding updating your application, the first trick is actually determining there is an upgrade available. There are various options for this, I'll assume you choose one based on your requirements.
Once you know there is an upgrade, you could push the user into the Browser with the download page open, rather than trying to do it yourself.
if you want to do it yourself, CodeModuleManager seems to have the APIs that you would need, though you may not be able to install it (especially over the top of an existing version), without a restart.
08-05-2008 09:46 AM
Just to add to that, you can use CodeModuleManager.promptForResetIfRequired() to prompt the user to reboot. Invoking this method will have no effect if there a reset isn't required. We added this method in JDE v4.2.0.
Tariq
08-05-2008 10:08 AM
08-06-2008 12:42 AM
thanx a lot peter and tariq ..
that is really helpful
08-06-2008 04:34 AM
if ( rc == CodeModuleManager.CMM_OK_MODULE_MARKED_FOR_DELETIO
N ) { CodeModuleManager.promptForResetIfRequired(); tellUserMessage = "Please restart the device to remove the application"; } else
To use the promptForResetIfRequired() method, I've changed the code as above (I'm sure you can see where it goes). With this in place, the menu item has been reinstated.
12-24-2008 08:04 AM
I have used same code for unistalling the application. Is there any other api to uninstall the application without reset the device. In BBDevice i can uninstalling application without restarting the device through the 'options' menu item. But with this code snippet, user gets prompted to restart the device if the uninstall option is chosen from the context menu. Why is this and is it really required?
Advanced thanks for any reply.
01-02-2009 12:47 PM
Please see the link below. The same reasons also apply to deleting an application.
What Is - The reason a reset is required when upgrading an application