02-09-2009 10:32 AM
is it possible?
have read:
& in the light of this, have written a simple test app that hooks itself into various BB system processes as follows:
Session.getDefaultInstance().addFolderListener(oMy
BlackBerryPIMList oTaskList=(BlackBerryPIMList) PIM.getInstance().openPIMList(PIM.TODO_LIST, PIM.READ_WRITE);
oTaskList.addListener(oMyPIMTaskListener)
Application.getApplication().addGlobalEventListene
Then in response to an unload UI request, my test app does the following:
Session.getDefaultInstance().getStore().removeFold
BlackBerryPIMList oTaskList=(BlackBerryPIMList) PIM.getInstance().openPIMList(PIM.TODO_LIST, PIM.READ_WRITE);
oTaskList.removeListener(oMyPIMTaskListener);
Application.getApplication().removeGlobalEventList
I can then happliy proceed to Options->Advanced Options->Applications, choose my application and delete it *without* a dreaded re-boot. All good so far!
However,
if i want to implement the following BB system hooks:
ApplicationMenuItemRepository.getInstance().addMen
Session.addViewListener(oMyEmailOpenCloseListener)
And response to my test app unload UI request, do the following:
ApplicationMenuItemRepository.getInstance().remove
Session.removeViewListener(oEmailOpenCloseListener
Guess what? -When i go to delete the test app, I now need to reboot?! -Why?
The above certainly *have* been unhooked from the BB system in some way. They no longer appear on the BB Messages app list view menu or receive Open/Close events, yet somehow it would appear that a reference to my objects is still being held. How can I clear it? Is it a bug?
-Have tried invoking the System.gc() garbage collector but no luck.
Any bright ideas folks, or will it fall once again to poor Mark Sohm having to tell me it can't be done..
Solved! Go to Solution.
02-09-2009 03:02 PM
02-10-2009 09:22 PM
solved/hacked -kill the BB application.
-so eg wrt say:
Session.addViewListener(oMyEmailOpenCloseListener)
In my oMyEmailOpenCloseListener object, i define my own unload event handler which first unhooks itself from the BB messages App, and then kills it, comme ca:
Session.removeViewListener(this);
.
.
System.exit(0);
-bingo, no more references held, lol
02-10-2009 09:28 PM
02-27-2009 06:08 AM
hi...
got same problem....
still waiting for solution....
02-27-2009 07:59 AM
listener in rim applications hold a reference to your application when they are added. if you exit your application there are still references and the application object is not destroyed.
the reason why the reference is not destroyed by a System.exit is the way listener work on the BB, they are running in the context of the application they were added to.
02-28-2009 10:24 AM
Simon, yog123
Yes, what you say is correct.
But i overcame this by using Session.addViewListener(oMyEmailOpenCloseListener) to hook into the BB Messaging application. Then on the first open event received by oMyEmailOpenCloseListener, I was able to create a global event listener: Application.getApplication().addGlobalEventListene
Then from my backround application I could fire a global event that would be received by the oMyGlobalEventListener from within the BB Messaging process and hence then unhook & call System.exit(0).
Sadly, wrt:
ApplicationMenuItemRepository.getInstance().addMen
I have been unable to find any way of successfully removing all references to oMyMenuItem.
Any insight here would be fantastic..
03-04-2009 02:58 PM
03-13-2009 07:31 AM - edited 03-13-2009 07:53 AM
Mark, thx for taking the time 2 respond,
But sadly not so.
wrt:
ApplicationMenuItemRepository.getInstance().addMen
when i do the following (with the same oMyMenuItem reference):
ApplicationMenuItemRepository.getInstance().remove
then certainly, it does remove the menu item from the menu.
But this thread is about being able to uninstall my application without a reboot.
And yet when i invoke my unloadTestApp() function: while it seems as if oMyMenuItem has indeed been successfully unregistered, because it no longer appears on the BB Messages list screen menu, something (& i think, not the BB Messaging app) is nevertheless retaining a reference because when i try to delete my application from Options->Advanced Options->Applications, it prompts for a re-boot.
But if you read back through this thread you will see that i have successfully unloaded/unregistered other BB event hooks (that would otherwise also cause a re-boot) via the same unloadTestApp() function, & avoided the dreaded re-boot.
***
NB: have also tried to create my BB Messages list menu item without using
ApplicationMenuItemRepository.getInstance().addMen
But this just presents a different problem:
in my overridden MenuItem.run() function I can get to the selected list field by calling:
UiApplication oUiApp=UiApplication.getUiApplication();
Screen oScreen=oUiApp.getActiveScreen();
Field oField=oScreen.getFieldWithFocus();
but have failed to discover how I can possibly acquire the associated Message object which i imagine is snuggled somewhere deep within the oField item. Any help here would provide me with a suitable workaround..
v313, ever hopeful of a resolution..