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
appodictic
Posts: 6
Registered: ‎10-13-2009
My Device: Not Specified

Working with pushScreen() popScreen()

I am writing a multi-screen application I am kinda confused by the semantics of pushScreen popScreen.

 

The way my application works the first two screens are one time configuration screens, assuming they have configured the variables on startup you should go to the third screen.

 

        if (getSRPInfo().getElement(SRPInfo.EMAIL).equals("")){
            this.pushScreen( email );
        }
        if (!getSRPInfo().getElement(SRPInfo.EMAIL).equals("") && getSRPInfo().getElement(SRPInfo.SAVE_LOC).equals("")){
            this.pushScreen( email );
            this.pushScreen( save );
        }
        if (!getSRPInfo().getElement(SRPInfo.EMAIL).equals("") && !getSRPInfo().getElement(SRPInfo.SAVE_LOC).equals("")){
            this.pushScreen( email );
            this.pushScreen( save );
            this.pushScreen(down);
        }

 

Then each screen can only push to the next screen and pop to the previous screen. Am I missing something ? How can I move from screen 1 to 3 ? What other options between push and pop screen?

 

Please use plain text.
Developer
Blanc
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: Working with pushScreen() popScreen()

 

Hi, can you be more particular and detail about your requirement? you are nowhere popping   the screen, continusly pushing the screens, i suppose you will get a IllegalStateException when you run your code, ( because you are pushing email, save screen without popping, as it is given in your code snippet).

 

 

Thanks and Regards,
PraveenGoparaju.
Please use plain text.
New Developer
appodictic
Posts: 6
Registered: ‎10-13-2009
My Device: Not Specified

Re: Working with pushScreen() popScreen()

Thank you for your comments.

 

My Use case is:

I have three screens.

 

At any time I should be able to move from screen3 to screen1 or screen2. So the menu of screen3 should have items that take you to the other screens.

 

Screen 1 and screen 2 are configuration screens. They set objects saved on the blackberry. So logically if these variables are already set I would skip the first two screens and go right to screen 3.

 

pushScreen and popScreen work on a stack and that is relly not what I want. I want to be able to move between any screen in almost any order. 3->1, 3->2, 1->2, 2->3. 

 

Here is this in more detail.

screen1 is a username and password screen. This is normally only filled out once. The info is saved to the device.

When the app starts up if checks if the object is in the persistant store, if it is it should advance to screen2.

 

Screen 2 is a save location screen. This again saves information to the device. If this information is already present on startup the app should start on screen3.

 

So after the user is configured properly, the application should start on screen3. However they may want to change the information on screen1 or screen2.

 

The only way I have been able to solve this..Is to push all screens, and not have random access the application can only move forward with push and backwards with pop. Can I have random access?

Please use plain text.
Developer
macdan
Posts: 157
Registered: ‎05-10-2009
My Device: Not Specified

Re: Working with pushScreen() popScreen()

 

Rather than push all screens and trying to figure their order.  Only push one of them at a time - the working screen.  From that screen allow the user to move to the other screens by first pushing the target screen, then popping the source screen.  This way only the present working screen is on the stack.  (except for the brief moment in time when the source and target are both on the stack) You need to use try-catch for the pops to avoid exceptions.  The following is an example where the User is on help screen and wants to go to email screen:

 

 

pushScreen(helpScreen);

 try

 {

             UiApplication.getUiApplication().popScreen( helpScreen);            

}

catch(IllegalArgumentException e)

{

         /*screen is not on the stack - do nothing*/

}

 

Please use plain text.
Developer
macdan
Posts: 157
Registered: ‎05-10-2009
My Device: Not Specified

Re: Working with pushScreen() popScreen()

 

Posting again to fix my error on pushScreen.

 

pushScreen(emailScreen);

 try

 {

             UiApplication.getUiApplication().popScreen( helpScreen);            

}

catch(IllegalArgumentException e)

{

         /*screen is not on the stack - do nothing*/

}

 

 

Please use plain text.
Super Contributor
lyon819
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.
My Carrier: TT

Re: Working with pushScreen() popScreen()

UiApplication.getUiApplication().pushScreen( new ClientScreen(uuid));

 

-Fight with BB10
Please use plain text.