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
Highlighted
Developer
Posts: 242
Registered: ‎02-19-2013
My Device: 9500
My Carrier: _
Accepted Solution

Application not working and satisfy condition.

I have code this method. Its not executing even a single line of run method here. Please explain why its so.

 

public static synchronized void pushGlobalLockScreen() {
        UiApplication.getUiApplication().invokeLater(new Runnable() {

            public void run() {
                // GlobalVars.currentLockScreen = new LockScreen();
                GlobalVars.currentLockScreen = new LockScreen();
                GlobalVars.lockStatus = GlobalVars.STATUS_LOCKED;
                try {
                    LocalStorage.setSmartFuzzLock(true);
                } catch (MySystemException e) {
                    MySystemException.addLog(e.getError());
                }
                UiApplication.getUiApplication().pushGlobalScreen(GlobalVars.currentLockScreen, 1, UiEngine.GLOBAL_MODAL);
                // UiApplication.getUiApplication().requestForeground();
                // UiApplication.getUiApplication().pushScreen(GlobalVars.currentLockScreen);

            }
        });
    }

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

Re: Application not working and satisfy condition.

If you have used the debugger and stepped through this code and it is in fact executing the invokeLater, then the reason is that the code executes this is running on the Event Thread and does not give it up.  You are probably coding some 'wait' rather than relinquishing control.  Step through the code that runs after this and see what happens - I think it is that code that is causing the problem, not the code you have shown.

 

If you have not debugged this code, then please do. 

 

That said, there are some things you might consider coding differently in the supplied code:

 

public static synchronized void pushGlobalLockScreen() {

- why synchronized?

 

                GlobalVars.currentLockScreen = new LockScreen();
GlobalVars.lockStatus = GlobalVars.STATUS_LOCKED;
                try {
                    LocalStorage.setSmartFuzzLock(true);
                } catch (MySystemException e) {
                    MySystemException.addLog(e.getError());
                }

 

This code probably does not have to run on the Event Thread.  I would consider running it before you start code that does have to be on the Event Thread. 

 

UiApplication.getUiApplication().pushGlobalScreen(GlobalVars.currentLockScreen, 1, UiEngine.GLOBAL_MODAL);

 

I might be wrong, but from memory, this code does not need to run on the Event Thread either.  And it is not blocking, so you code should run past it just fine. 

 

Be aware that this will push a screen that runs in front of all the screens (other than any other global screens).  This global screen is not really part of your application. 

Developer
Posts: 242
Registered: ‎02-19-2013
My Device: 9500
My Carrier: _

Re: Application not working and satisfy condition.

I am opening this screen on certain input. actually my application is running in background.

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

Re: Application not working and satisfy condition.

OK, what about the rest of my post?