08-22-2012 01:54 AM
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 ?
Solved! Go to Solution.
08-22-2012 02:11 AM - edited 08-22-2012 02:14 AM
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!!
08-22-2012 02:20 AM
08-22-2012 02:24 AM
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.
08-22-2012 02:25 AM - edited 08-22-2012 02:27 AM
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..
08-22-2012 02:29 AM
08-22-2012 04:44 AM
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.
08-22-2012 07:06 AM