Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 16
Registered: ‎08-29-2008
My Device: Not Specified
Accepted Solution

uninstall without device reboot, OS4.2

is it possible?

 

have read:

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/What_Is...

 

& in the light of this, have written a simple test app that hooks itself into various BB system processes as follows:

 

Session.getDefaultInstance().addFolderListener(oMyFolderListener);


BlackBerryPIMList oTaskList=(BlackBerryPIMList) PIM.getInstance().openPIMList(PIM.TODO_LIST, PIM.READ_WRITE);

oTaskList.addListener(oMyPIMTaskListener)

 

Application.getApplication().addGlobalEventListener(oMyGlobalEventListener);

 

Then in response to an unload UI request, my test app does the following:

 

Session.getDefaultInstance().getStore().removeFolderListener(oMyFolderListener);

 

BlackBerryPIMList oTaskList=(BlackBerryPIMList) PIM.getInstance().openPIMList(PIM.TODO_LIST, PIM.READ_WRITE);

oTaskList.removeListener(oMyPIMTaskListener);

 

Application.getApplication().removeGlobalEventListener(oMyGlobalEventListener);

 

 

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().addMenuItem(ApplicationMenuItemRepository.MENUITEM_MESSAGE_LIST,oMyMenuItem);

 

Session.addViewListener(oMyEmailOpenCloseListener);

 

And response to my test app unload UI request, do the following:

 

ApplicationMenuItemRepository.getInstance().removeMenuItem(ApplicationMenuItemRepository.MENUITEM_MESSAGE_LIST,oMyMenuItem);

 

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..

 

 

 

 

 

 

Highlighted
Developer
Posts: 16
Registered: ‎08-29-2008
My Device: Not Specified

Re: uninstall without device reboot, OS4.2

c,mon Mark throw me a bone..
Developer
Posts: 16
Registered: ‎08-29-2008
My Device: Not Specified

Re: uninstall without device reboot, OS4.2

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

 

 

 

 

 

 

Developer
Posts: 16
Registered: ‎08-29-2008
My Device: Not Specified

Re: uninstall without device reboot, OS4.2

actually, thinkin about it, why do i even need 2 botha 2 unhook? -just killing the sucka should do it.. will try it tommoz & post the results - 4 now tho, bedtime (uk)
Developer
Posts: 51
Registered: ‎07-15-2008
My Device: Not Specified

Re: uninstall without device reboot, OS4.2

hi...

 

got same problem....

 

still waiting for solution....

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: uninstall without device reboot, OS4.2

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. 

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 16
Registered: ‎08-29-2008
My Device: Not Specified

Re: uninstall without device reboot, OS4.2

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().addGlobalEventListener(oMyGlobalEventListener)

 

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().addMenuItem(ApplicationMenuItemRepository.MENUITEM_MESSAGE_LIST,oMyMenuItem)

I have been unable to find any way of successfully removing all references to oMyMenuItem.

Any insight here would be fantastic..

 

BlackBerry Development Advisor
Posts: 15,753
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: uninstall without device reboot, OS4.2

An ApplicationMenuItem can remove itself.  The same instance that was added must be passed to the ApplicationMenuItemRepository.removeMenuItem method.  You can store a reference to the original object in the BlackBerry RuntimeStore.  Then, when you want to remove it read the object from the RuntimeStore and pass it to the removeMenuItem method.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 16
Registered: ‎08-29-2008
My Device: Not Specified

Re: uninstall without device reboot, OS4.2

[ Edited ]

Mark, thx for taking the time 2 respond,

But sadly not so.


wrt:

  ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_MESSAGE_LIST,oMyMenuItem)

when i do the following (with the same oMyMenuItem reference):

  ApplicationMenuItemRepository.getInstance().removeMenuItem(ApplicationMenuItemRepository.MENUITEM_MESSAGE_LIST,oMyMenuItem);

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().addMenuItem by instead creating a dynamic menu item derived from MenuItem.

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..

Message Edited by violet313 on 03-13-2009 07:53 AM