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
New Developer
Posts: 3
Registered: ‎05-16-2009
My Device: Not Specified
Accepted Solution

Pushing an poping screens

ok I have an app that launches a main screen with several buttons, when a button is clicked, i need it to push the new screen. But my screen extends MainScreen and you can only push and pop with UiApplication. So how is this done?

 

Ty for your time...

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Pushing an poping screens

UiApplication.getUiApplication() is a static method, so you can use UiApplication.getUiApplication().pushScreen()

 

 

 

 

New Developer
Posts: 3
Registered: ‎05-16-2009
My Device: Not Specified

Re: Pushing an poping screens

Ok thats great, ty.

 

Now a follow up question...

 

popScreen requires that a screen object be passed to it, but how do i get the currect screen object so i can pop it? also after I pop it, do I need to specifically destroy the object or will the garbage collections get it for me?

 

heres my call...

 

 UiApplication.getUiApplication().pushScreen(new ScreenTwo());

 

since im passing it a new ScreenTwo() object, wont it be like a memory leak when the method that called it goes out of scope?

 

Ty again.

Developer
Posts: 131
Registered: ‎08-13-2008
My Device: Not Specified

Re: Pushing an poping screens

[ Edited ]

Create a reference then!

 

MainScreen screen=new MainScreen(); //now you can recall it!

pushScreen(screen);

popScreen(screen);

doWhatever(screen);

 

A stack of screens is maintained by UiApplication so unless the application is closed, it won't go out of scope.

Message Edited by KeniF on 05-17-2009 01:20 AM
Highlighted
Developer
Posts: 57
Registered: ‎04-07-2009
My Device: 8300

Re: Pushing an poping screens

You can also use

this.close()

 

rather than using pop.