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
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930
Accepted Solution

OnExposed() method problem

Suppose there are 3 screens Screen A,Screen B,Screen C. From screen A i get navigated to screen B,from screen B i get navigated to screen C. When i am in screen C and if i press back button i am navigated to screen B. I want to write onexposed() in screen B.in this how can i know that from which screen i am navigating to screen B ?

Please use plain text.
Developer
Kiran_Snist
Posts: 174
Registered: ‎01-25-2011
My Device: Not Specified

Re: OnExposed() method problem

[ Edited ]

One thing u can do is...in some method in Screen B u can call "UiApplication.getUiApplication().getActiveScreen()"
this to check the instance of current screen and accomplish ur task accordingly like popping or pushing new screen B or wat ever!!

Please use plain text.
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930

Re: OnExposed() method problem

If i invoke UiApplication.getUiApplication().getActiveScreen() in screen B, It always returns screen B. I want to check from which screen screen B is receiving foreground?
Please use plain text.
Developer
rishikeshsinghpbh
Posts: 121
Registered: ‎05-31-2012
My Device: 9900

Re: OnExposed() method problem

Hi,

 For this u can also make ur own protocols in the following way--

 

1. Make constants denoting each screen;e.g

public static final int A=100

public static final int B=101

public static final int C=102

 

2.now declare a static var denoting the PREVIOUS SCREEN ,e.g

public static int PREVIOUS_SCREEN;

 

Now set the value of PREVIOUS_SCREEN on the basis of screen and retieve its value wherever you require.

 

 

Rishikesh Singh
Please use plain text.
Developer
Kiran_Snist
Posts: 174
Registered: ‎01-25-2011
My Device: Not Specified

Re: OnExposed() method problem

[ Edited ]

I didn't mean to push the screen B n check just call a method in screen B.... a static method or wat ever .. I should have asked u to call that getActiveScreen() from any where. Since u were referring to Screen B... I thought it would be the standard way to do... Any way getActiveScreen is probably the best way to accomplish ur task I wonder.. After u call that method u can push ur Screen B..

Please use plain text.
Developer
simon_hain
Posts: 16,190
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: OnExposed() method problem

easy (and dirty) way would be to check getScreenBelow().
a better way would be to either manager the screen stack in a third class that all screens have in common (a service) or give the screen some information about it's state, using a set method or the constructor.
----------------------------------------------------------
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
Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: OnExposed() method problem

And another simple approach, which I like because it is 'self contained' (i.e. the logic is within the screen itself) is to set a flag appropriately, that you test in the onExposed.  So if Screen B pushes Screen C, it sets this flag.  Later, in onExposed(), when this flag is set, Screen B does whatever is needed (and resets the flag).  If the flag is not set, Screen B does not do it.

 

So you can detect which Screen was pushed by the flag setting and act accordingly.

 

There is no way that onExposed() can be invoked, once you push the screen, until that screen has been closed/popped.

Please use plain text.
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930

Re: OnExposed() method problem

Thanx peter
Please use plain text.