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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Developer
Posts: 9
Registered: ‎05-04-2009
My Device: Not Specified

Error trying to pushScreen inside a thread

Hi,

 

We are trying to push the screen PopUpColeta (below) inside the TimeAuditor class which extends Thread (details below) but we get the following exception: "java.lang.IllegalStateException: UI engine accessed without holding the event lock"

 

public class PopUpColeta extends PopupScreen implements KeyListener

 

public class TimeAuditor extends Thread

 

UiApplication.getUiApplication().pushScreen(popUpColeta)

 

For some reason the pushScreen command above works fine when we place it inside the MainScreen.

 

We are using BlackBerry Component Pack 4.5.0

 

Thanks!

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Error trying to pushScreen inside a thread

[ Edited ]

Place the pushScreen or popScreen inside of a Runnable and pass this Runnable to UiApplication.invokeLater()

 

Something like this:

/** * Stop the status display */ private void stopStatusDisplay() { if (m_statusDisplay != null){ m_app.invokeLater(new Runnable() { public void run()

{ m_statusDisplay.close(); m_statusDisplay = null; } }); } }

 

 

Note that I'm storing an instance of my application (m_app), since you can't always rely on UiApplication.getApplication(), depending on the context of the thread that is calling the UI.

 

Message Edited by RexDoug on 07-25-2009 10:47 AM
Developer
Posts: 88
Registered: ‎07-11-2009
My Device: Not Specified

Re: Error trying to pushScreen inside a thread

RexDoug:  In what context can you not rely on the UiApplication.getApplication() method?
Highlighted
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Error trying to pushScreen inside a thread

This static method will return the current UiApplication, which may not be your application in certain circumstances.

 

For example, your app is called form a Message listener or Phone listener. In this case, the application context belongs to the calling app, not yours.