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 Contributor
PrateekJ
Posts: 7
Registered: ‎04-27-2013
My Device: 9550
My Carrier: 9960113665
Accepted Solution

Pop to home screen

I want to pop to home screen from my fifth screen, where I have a button which takes to home

 

I have refered this link

http://stackoverflow.com/questions/8380558/pop-to-home-screen

 

and have put same code, but application hangs, but does not crashes.

 

any help on how to implement Pop Screen will be really grateful.

 

Thanks

Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Pop to home screen

If you use the code supplied (see later), all your screens will be popped off the display stack, leaving nothing there.  What happens then depends on the application, but usually it will either close or hang with no screen displayed.  I think you are seeing the later.

 

If you want to show the user the home screen, but still retain the screen stack you have, then just use

UiApplication.getUiApplication().requestBackground();

 

This is effectively the same as the user using the task switcher to switch to the home screen.

 

If you use this, then, when  the user selects your icon again, they will be returned to the screen that they were on before the 'requestBackground()' was issued. 

 

If this is not what you want, please can you describe what you would actually like to happen. 

 

-----------------------------------------------------

 

Popscreen code from stackoverflow Thread:

 

public static void popupScreens()
{
    int screenCount = UiApplication.getUiApplication().getScreenCount();//Gives how many screens are active state in background;
    for (int i = 0; i < screenCount; i++)
    {
        Screen screen = UiApplication.getUiApplication().getActiveScreen();
        UiApplication.getUiApplication().popScreen(screen);
    }
}

Please use plain text.
New Contributor
PrateekJ
Posts: 7
Registered: ‎04-27-2013
My Device: 9550
My Carrier: 9960113665

Re: Pop to home screen

Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Pop to home screen

How does the code on that link get you to the home screen?

Please use plain text.
New Contributor
PrateekJ
Posts: 7
Registered: ‎04-27-2013
My Device: 9550
My Carrier: 9960113665

Re: Pop to home screen

This link in that answer did what I wanted to do..
Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Pop to home screen

[ Edited ]

According to your first post, you wanted to do this:

 

"I want to pop to home screen from my fifth screen"

 

How did it help you do this?

 

Ah, I see, the link you supplied was talking about Esc, but also referenced another response here:

http://stackoverflow.com/questions/15815118/popping-multiple-screens-in-a-blackberry-application/158...

 

That link did not delete all the screens off the stack, it just deleted all bar 1.  This will not take you back the Home Screen, but it will not fail the way that the code you originally supplied will, becuase it leaves one screen on the stack.

 

For the record, the code is as follows:

 

   publicvoid popToRoot(){
     
UiApplication app =UiApplication.getUiApplication();
     
while(app.getScreenCount()>1){
         app
.popScreen(app.getActiveScreen());
     
}
  
}

 

 

Please use plain text.