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
Trusted Contributor
trupti
Posts: 242
Registered: ‎03-16-2010
Accepted Solution

Return to original Screen

 

Hi,

 

   I have Screen1 & Screen2 that extends MainScreen. I call Uiapplication.getUiApplication().pushScreen(new Screen2()); from Screen1. now when the user clicks on a button in Screen2, I want it to return to Screen1 and update the details in Screen1.

 

How do I achive it ?

 

 

Thanks

 


--------------------------------------------------------------------------------
For any helpful answers give kudo's (star) to the helper.
Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008

Re: Return to original Screen

You close() or popscreen() Screen2 and SCreen1 will now be at the top of the screen stack, and displayed.

 

Please use plain text.
Trusted Contributor
trupti
Posts: 242
Registered: ‎03-16-2010

Re: Return to original Screen

 

Thank you.

 

Is their a way where I can close current screen and open second screen. I have Screen1 & Screen2. I want to close Screen1 and open Screen2, so when my click on Close in Screen2, my application gets closed amd screen1 is not visible.

 

Thanks

 

 


--------------------------------------------------------------------------------
For any helpful answers give kudo's (star) to the helper.
Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008

Re: Return to original Screen

If you close the last screen in your display stack, the application closes.

 

You can override the close() method in a screen and call requestBackground() to force the app to background (no visible screen). When you app icon is clicked again, you will come back for foreground and your  screen will again be visible.

 

 

 

Please use plain text.
Trusted Contributor
trupti
Posts: 242
Registered: ‎03-16-2010

Re: Return to original Screen

 

Do you mean to say, that in Screen1, I close the screen

public void close() {

   UiApplication.getInstance().getUiApplication().requestBackground();

  super.close();

 

What will this do, I didn't get it? And how this will help get my Screen2 ?

 

I was thinking of some other option like having another screen on top of Screen1.

 

class SrartUpScreen extends MainScreen {
    public SrartUpScreen() {    
    /*     
        Screen1 screen1 = new Screen1();
        UiApplication.getUiApplication().pushModalScreen(screen1);
        net.rim.device.api.ui.component.Dialog.inform("Back here");
        if (screen1.getContinuePressed() == true) {
            net.rim.device.api.ui.component.Dialog.inform("Continue Pressed");
            UiApplication.getUiApplication().pushScreen(new Screen2());

        }
     */       
        setTitle("Welcome to iBeloved");
    }
}

 

But it seems that creating instance in constructor() & calling pushScreen is giving error. If I comment that part then it shows proeprly. If I add a button then it will work, but I wanted to do it without user clicking anything.

 

Any ideas. A timer or so can help me ? Or the option that u r showing can that be of good help without user clicking again and straight away going from  screen1 to screen2 and screen1 gets closed.

 

Thanks

 

 

 


--------------------------------------------------------------------------------
For any helpful answers give kudo's (star) to the helper.
Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008

Re: Return to original Screen

You don't want to instantiate and/or push a screen in the constructor of another screen. Your MainScreen constructor is probably being called before you enter the event dispatcher anyway, so you would get an "illegal state" exception of some sort.

 

Can you describe the steps you want to accomplish, like #1, #2, ans so on?

 

I'm having a hard time understanding what your desired end result is.

 

Please use plain text.
Trusted Contributor
trupti
Posts: 242
Registered: ‎03-16-2010

Re: Return to original Screen

 

I have 3 screens - Screen1, Screen2 & Screen3. At present the scenario is :

From UiApplication, Screen1 is called. On a button press in Screen1, Screen2 is called & from Screen2, Screen3 is called.

So when I close the Screen2, I see Screen1 and then I got to press close on Screen1 to exit the application.

 

What I want is:-

 

  1. When or Bedore I go to Screen2 from Screen1, screen1 should be closed, so it is out of the stack. and hence I can call System.exit from Screen2 only - I need not look after Screen1 any more.

I know that I can straight away call System.exit from Screen2, though Screen1 is on the queue, but I believe that will not be good work. So I want a way how I can close Screen1, either in Screen2 or before showing Screen2.

 

I hope I have made myself very clear.

 

 

Thanks 

 

 


--------------------------------------------------------------------------------
For any helpful answers give kudo's (star) to the helper.
Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008

Re: Return to original Screen

I would call System.exit(0) from screen2, this is fine. The system will close the screen1 and clean up the memory.

 

Please use plain text.
Trusted Contributor
trupti
Posts: 242
Registered: ‎03-16-2010

Re: Return to original Screen

 

Ok. Just wanted to opt a better option. Nothing else. Thanks a lot.


--------------------------------------------------------------------------------
For any helpful answers give kudo's (star) to the helper.
Please use plain text.