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
dkumar
Posts: 113
Registered: ‎04-09-2009

How do I completely remove/delete a MainScreen object from UiApplication?

Hi,

   How do I completely remove a MainScreen object from UiApplication? PopScreen() only removes it from the Display stack and in this case, it still stays in the memory.

 

 Why do I want to remove the screen from UiApplication?

 

-  I have a common screen ( which displays some run time data ) class derived from MainScreen. Based on the requirement, I remove/add fields and updates the data accordingly. If I just use PopScreen()/PushScreen(), it doesnt wipe out the old data and fields. Hence I want to completely remove/delete the screen and its fields/data before I display the next data sets.

 

Another question?

- Is there any event gets fired when a screen get displayed? I tried onDisplay() . But didn't work..

 

Thanks in advance..

 

Regards,

-DK

Please use plain text.
Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008

Re: How do I completely remove/delete a MainScreen object from UiApplication?

[ Edited ]

If you are holding a reference to the screen or any fields on the screen after popping it, then it will stick around and not get garbage collected. The fields reference the screen (or at least the screen delegate) through Field.getManager(). If you want, you could delete all the fields from the screen in Screen.onUndisplay() to ensure that the fields are at least no longer referencing their manager.

 

onDisplay() is called when you use pushScreen(). If you want to know when the screen is visible or not use onVisibilityChange().

Message Edited by mreed on 06-02-2009 01:17 PM
Please use plain text.
Developer
dkumar
Posts: 113
Registered: ‎04-09-2009

Re: How do I completely remove/delete a MainScreen object from UiApplication?

Hi Reed,

   Thanks for your quick response.

 

 I have a customized vertical field manager class derived from VerticalFieldManager that holds all the fields.

 

I tried the following: ( As onDisplay() / onUnDisplay() are deprecated I used the onUiEngineAttached() )

 

protected void onUiEngineAttached(boolean attached){ if(attached == true){ //initManager(); }else{ // Dialog.alert("Main Menu detached"); vfm.deleteAll(); } }

 

 

I get an exception IndexOutOfBoundException. As per the documents, deleteAll() should delete all the fields it contains. Am I missing something?

 

Thanks,

 

Regards,

-DK

Please use plain text.
Administrator
MSohm
Posts: 14,064
Registered: ‎07-09-2008
My Carrier: Bell

Re: How do I completely remove/delete a MainScreen object from UiApplication?

What BlackBerry Smartphone model and BlackBerry handheld software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.
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
Please use plain text.
Developer
dkumar
Posts: 113
Registered: ‎04-09-2009

Re: How do I completely remove/delete a MainScreen object from UiApplication?

Hi,

  Right now I am testing on the below device, but my traget is the common BlackBerry device.

 

 

  Model:  BlackBerry SmartPhone 9530 (storm)

  Version: v4.7.0.148(Platform 4.0.0.181)

 

BlackBerry JDE version:  4.7.0.41

 

 

Thanks,

-DK

 

 

 

Please use plain text.