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
jeyaprakash
Posts: 33
Registered: ‎07-16-2008
My Device: bold

Uncaught exception: attempt to push screen while already displayed

My application return this exception when i call My previous Mainscreen

 

 

UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { UiApplication.getUiApplication().pushScreen(firstscreen); } });

 

????????

 

Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Uncaught exception: attempt to push screen while already displayed

[ Edited ]

I'm not really sure what you are asking. You normally push the screen before starting the app.

I have something called Phlauncher that starts like the code below. invokelater is for running

"stuff" that happens while the app is running. For example, I have stuff like this line,   invokeLater(new NavigateTo(url,this)); 

 

 

public static void main(String[] args) {
    Phlauncher app= new Phlauncher(new DefPhluParam() );
        app.enterEventDispatcher();
    }
    public Phlauncher(PhluParam pp )
    {          
            _mainScreen = new PhluScreen(this);
        _mainScreen.add(new BitmapField(_oBitmap)); 
       // rtc=new RichTextField("loading");
               pushScreen(_mainScreen);

Message Edited by marchywka on 09-19-2008 09:13 AM
New Developer
jeyaprakash
Posts: 33
Registered: ‎07-16-2008
My Device: bold

Re: Uncaught exception: attempt to push screen while already displayed

hi marchywk

 

am calling a screen that was pused already it was in background for example my firstscreen is in background i do some stuf with my second screen after tat i calling my first screen object using

     

        pushscrren(firstscreen);

 

method i got Uncaut exception attempt to push screen while already displayed wats my problem...

 

by..

jp

Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Uncaught exception: attempt to push screen while already displayed

AFAIK you can push multiple screens but apparently it doesn't like the same screen pushed twice.

I've never had this problem as I just use one screen and modify the layout. I've actually

got my own stack of rendered fields and just change the screen layout,

Run something like this in invokelater,

 

_mainScreen.deleteAll();
   _mainScreen.add(field);   

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Uncaught exception: attempt to push screen while already displayed

jeyaprakash.  How do you get from your first to your second screen? 

 

If you do the standard BlackBerry thing, you will, from something like a menu handler in the first screen, use a push to go to the second screen.  Assuming you do that, then both your screens are on the 'stack', just the second one is on top of the first one.  So all you have to do is pop the second screen, and your first one will appear.

 

Does that help?

 

If not, can you clarify how you get to your second screen, and what you mean when you say your first screen is in background.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Uncaught exception: attempt to push screen while already displayed

if you push a screen it is pushed on the stack, on top of all screens that are already there. only the topmost screen is displayed.
if you want to display the previous screen you have to pop the current one, using popScreen(getActiveScreen()) or something similar.

or you can use a single screen to display, has some merits and some backdraws.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
jeyaprakash
Posts: 33
Registered: ‎07-16-2008
My Device: bold

Uncaught exception: attempt to push screen while already displayed

Thanku all

             my problem solved i delete my activescreen using popscreen( currentscreen) before switching ..