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 Contributor
Posts: 9
Registered: ‎10-07-2011
My Device: blackberry torch
My Carrier: airtel

cannot push global screen of my uiapplication when message is clicked in the message list app of blackberry

Hi I have made an application for facebook/gtalk in which when the user is in the background he should get message notifications and when he clicks on the messages. he should see the message in the custom screen which i have created for the uiapplication. I am doing this by pushing a global screen .but is raising a IllegalStateException.I donnot know why.if this is not the right way ..please direct me .

New Contributor
Posts: 9
Registered: ‎10-07-2011
My Device: blackberry torch
My Carrier: airtel

Re: cannot push global screen of my uiapplication when message is clicked in the message list app of blackberry

Actually the thing is ..My app is a gtalk client And when ever app goes in the background .new chat messages should appear in the blackberry message app.I integrated my app with the bbmessage app.when I get a message(whenever my app is in background) i create a chat screen using a thread running in background for my uiapplication.  But when ever i click on the chat message in the bbmessage app .I push a that chat screen as global screen but it raises an illegal State Exception.please help 

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: cannot push global screen of my uiapplication when message is clicked in the message list app of blackberry

welcome to the support forums.
usually an illegal state exception has a meaningful detail message, for example "ui accessed without event lock", which would mean you have to use invokelater or another method to gain the eventlock.
----------------------------------------------------------
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
Highlighted
New Contributor
Posts: 9
Registered: ‎10-07-2011
My Device: blackberry torch
My Carrier: airtel

Re: cannot push global screen of my uiapplication when message is clicked in the message list app of blackberry

this is the code  in an class which extends Application menu item  's run

 

                UiAppliacation.getUiApplication.invokelater(new Runnable()
                {
                    public void run() {
                               
                                UiApplication.getUiApplication().pushGlobalScreen(theScreen,0,UiEngine.GLOBAL_MODAL);
                                 if(ScreenManager.getNotificationCountIndicator()<=0)
                                 {
                                     AlertManager.changeApplicationIcon(Constants.APPNORMALICON);
                                     LED.setState(LED.STATE_OFF);
                                 }
                                 ScreenManager.SetNotificationTrayIndicator(ScreenManager.getNotificationCountIndicator()-1);
                                 //AlertManager.stopBackgroundAlert();
                        }
                    });
                }
                

I have taken all  the locks .I guess lock is not a problem. there is something else.

I tried using locks.

 

 

 if i create a screen  when my application is in the back ground  the different managers are not properly initialized(i guess)and when i push that screen globally it raises an illegal state exception and the reason is field.assertlayoutcomplete 

 

 

or when i create a screen in the background and push my screen using Uiapplication.getUipplication.requestForeground .it works properly.

 

 

please help.

 

 

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: cannot push global screen of my uiapplication when message is clicked in the message list app of blackberry

first, use:

synchronized (UiApplication.getEventLock()) {

 instead of:

UiAppliacation.getUiApplication.invokelater(new Runnable()
                {

* You can omit the runnable object.

 

 Second, use:

UiApplication.getUiApplication().pushGlobalScreen(theScreen,0,UiEngine.GLOBAL_QUEUE | UiEngine.GLOBAL_MODAL);

 E.