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
girishthakr
Posts: 232
Registered: ‎12-15-2008
My Device: 9700
My Carrier: Vodafone India
Accepted Solution

How to Go back to previous screen

I want to go back to previous screen on a press of button in my application.

 

Same thing as we go back by pressing "back arrow "  button on blackberry.

 

What I need to call ?  I mean if I want to go another screen then simply I  can call that screen.

 

But here the scenario is :

 

I m at one of my screen and suddenly one msg comes in my app and I m showing that(msg) on screen(not popup) from that screen I want  to go back

I can do it by pressing back arrow button on Blackberry .

 

But I want to give one OK button so that on click of it I will go back to previous screen

 

Thx in advance  :smileyhappy:

 

 

Please use plain text.
Developer
Posts: 432
Registered: ‎02-23-2009
My Device: Not Specified

Re: How to Go back to previous screen

Use PopScreen() method to pop up current screen.

 


Press the kudos button to thank the user who helped you.

If your problem was get solved then please mark the thread as "Accepted solution".

 

 

 

 

Deepesh Gupta
Please use plain text.
Developer
kanaksony
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: How to Go back to previous screen

Hi,

 

You can use:

 

UiApplication.getUiApplication().popScreen(Screen screen);

                                   

or,

 

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

 

Kanak Sony

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Please use plain text.
Developer
mantaker
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: How to Go back to previous screen

[ Edited ]

I would not agree with Deepesh since popScreen() method is depricated... Use popScreen(Screen screen) method instead ..

 

Thanks! 

 

EDIT: was in edit mode .. 

Message Edited by mantaker on 04-16-2009 02:19 PM
--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Please use plain text.
Developer
girishthakr
Posts: 232
Registered: ‎12-15-2008
My Device: 9700
My Carrier: Vodafone India

Re: How to Go back to previous screen

Thx

 

I m trying all the methods. Once I finished I will let u know :smileyhappy:

 

Thx

Please use plain text.
Developer
girishthakr
Posts: 232
Registered: ‎12-15-2008
My Device: 9700
My Carrier: Vodafone India

Re: How to Go back to previous screen

Thnx all to ur replies....

 

Its working using  "UiApplication.getUiApplication().popScreen(this);"

 

now I m able to put  an   OK  button on click of which my previous screen is coming. Its working...

 

 

 

One more thing I want to ask: How to empty the stack which consists number of previous Screens.

 

Means as I m calling number of different Screens in application , they are stored in Stack ... right ? .. How to empty that stack ? Is JVM works here(garbage collector)??? if i m right :smileyindifferent:

 

Or What is the solution ???

 

Thnx

 

Please use plain text.
Developer
mantaker
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: How to Go back to previous screen

:smileyhappy: Garbage collector will not clean up the display stack for you .. You can get the number of screens by getScreenCount() method...
--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Please use plain text.
Developer
mantaker
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: How to Go back to previous screen

But the best practice I would suggest is, not to dump the display stack .. Pop the unnecessary screens immediately when you don't need that anymore ..

 

Cheers... 

--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Please use plain text.
Developer
girishthakr
Posts: 232
Registered: ‎12-15-2008
My Device: 9700
My Carrier: Vodafone India

Re: How to Go back to previous screen

I m unable  to uderstand this "the Pop the unnecessary screens immediately when you don't need that anymore .."

 

Is it to pop unnecessary screens  using above same  code ?

If yes then that code will popup the recent screen.

What about others which are left in stack ?  

Please use plain text.
Developer
mantaker
Posts: 1,477
Registered: ‎12-30-2008
My Device: Torch 9810

Re: How to Go back to previous screen

UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen().getScreenBelow());

 

can be used ..

 

Cheers.. 

--
Manimaran Selvan
Co-Founder, Tech Lead,
Equity Markets Research Group
Please use plain text.