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: 206
Registered: ‎07-02-2010
My Device: 8320 Curve
My Carrier: Vodacom
Accepted Solution

Correct way to pushScreen and not have old screens ... ?

Hope the subject is not misleading. I have an application that relies on pushing a lot of differnet screens. This i am able to do with no problem. The problem is when the user uses the "back button" on his/her BB. This takes the user to the previous "Old" Screen with old data. I want to know what is the right way to manage pushing screens.

 

Scenario:

 

User starts app, mainscreen is launched,

User clicks add button pushes screen to new screen and adds vehicle,

i pushscreen to mainscreen after added.

Now when user presses back button it take the user to the add screen with all the input still there.

 

I don't want this i want that screen to be removed from the heap or stack or memory or where ever it is stored.

 

Thanks in advance for the help guys.

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

Re: Correct way to pushScreen and not have old screens ... ?

popscreen?

----------------------------------------------------------
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: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm
My Carrier: Blackberry Developer

Re: Correct way to pushScreen and not have old screens ... ?

Hi, After pushing screen for adding.

 

 

 

UiApplication.getUiApplication().popScreen(Ui.getUiEngine().getActiveScreen());

----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 206
Registered: ‎07-02-2010
My Device: 8320 Curve
My Carrier: Vodacom

Re: Correct way to pushScreen and not have old screens ... ?

Getting Illegal argument exception, This is on a custom Dialog box that confirms the delete then once clicked ok takes user back to the main screen.

Developer
Posts: 206
Registered: ‎07-02-2010
My Device: 8320 Curve
My Carrier: Vodacom

Re: Correct way to pushScreen and not have old screens ... ?

[ Edited ]

Ekansh,

 

Do i add this code immediately after i pushscreen or on the other page's "Load" ?

Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: Correct way to pushScreen and not have old screens ... ?

[ Edited ]

what i understud u can do :

 

you can pop a screen before moving to a new screen and when user presses back button u can again push ur older screen with new data by overriding onClose method()

 

 

hey sorry for repeating data mentioned by others

Developer
Posts: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm
My Carrier: Blackberry Developer

Re: Correct way to pushScreen and not have old screens ... ?

on the Add Click,

 

Dont push back your mainscreen,

 

Write this code..it will bring you back to mainscreen.

 

e.g.

**********

MainScreen   --->  AddScreen

 

pop(AddScreen)

 

MainScreen 

**********

 

 

Finally you will have the mainscreen

 

Thanks

 

 

----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Highlighted
Developer
Posts: 178
Registered: ‎08-26-2009
My Device: Not Specified

Re: Correct way to pushScreen and not have old screens ... ?

User starts app, mainscreen is launched - Ok

User clicks add button pushes screen to new screen and adds vehicle - pushscreen

i pushscreen to mainscreen after added - Don't push screen here, merely pop the current screen.

 

 

 

 

Developer
Posts: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm
My Carrier: Blackberry Developer

Re: Correct way to pushScreen and not have old screens ... ?

Yes,

 

you are right.

 

----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 206
Registered: ‎07-02-2010
My Device: 8320 Curve
My Carrier: Vodacom

Re: Correct way to pushScreen and not have old screens ... ?

Thanks guys,

 

I have tried it and it works 80%, it is just a matter of getting the popping and pushing sequence write now Smiley Happy

 

Will mark Ekansh as solution as i used his code to get it working.