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
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10
My Carrier: Airtel
Accepted Solution

Need a method to call when the Screen Pop Up

Hi,

 

I have a requirement in my application. I have a Screen A from which i am moving to Screen B. When i am Pop the Screen B, i need a method which should be called in the Screen A. It is like same as onActivityResult() in Android.

I am currently using onExpose(). But this method is getting called for everything in the screen A. In menu click or in Button click also. Is there any other way to do this?

 

Please help..

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

Re: Need a method to call when the Screen Pop Up

You have two options that I can think of immediately, that do not involve changing anything in screen B.

 

1) use pushModal when you call screen B.  The statement immediately after the pushModal will be executed as soon as Screen B is popped.  Generally I try to avoid modal screens, but in this circumstance, it is probably what I would do.

 

2) Set a flag immediately before you push screen B.  Test the flag in onExposed().  If the flag is not set, then the onExposed has been called for some other reason and you can ignore it.  If the flag is set, then turn it off and process as you want, knowing that screen A has been exposed because Screen B has been popped. 

 

Either should work for you. 

Developer
Posts: 271
Registered: ‎12-24-2010
My Device: BlackBerry 10
My Carrier: Airtel

Re: Need a method to call when the Screen Pop Up

The second option has worked for me. But i did not understand your first point clearly. Can you please elaborate a little more. May be it will help me on future development.

 

Anywayz thanks.

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

Re: Need a method to call when the Screen Pop Up

Here is some sample code:

 

                SettingsScreen setScreen = new SettingsScreen();
                UiApplication.getUiApplication().pushModalScreen(setScreen);
                if (setScreen.getSettingsChangedFlag()) { // New settings

 

IN this code, the SettingsScreen can display or change some Settings.  If the user does not change anything, then the screen does not need to be refreshed.  If the user changes some values, then the screen must be refreshed.

 

In the above code, the SettingsScreen is pushed onto the the display, and then this code stops processing, and is not continued until the SettingsScreen has been closed.  At that point it can test a flag in the SettingsScreen to see if values were updated. 

 

Think about how you would do this using onExposed() - it is more complicated using that method I think. 

 

Hope this is clear.