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

New Developer
Posts: 2
Registered: ‎07-30-2008
My Device: Not Specified
Accepted Solution

pushGlobalScreen repaint?

Greetings--I'm testing in the 8120 Simulator, using the 4.3 JDE.


I've written code to pull up a MainScreen in the foreground when the simulator starts (this is a UI that will generally be used in the simulator only):


invokeLater(new Runnable() {
public void run() {
pushGlobalScreen(new TestUI(), 1, UiEngine.GLOBAL_MODAL);


I also set the app to "auto-run on startup" from the Eclipse project properties.


I tried the pushGlobalScreen without running it in the context of invokeLater; it generated a runtime exception. I also tried it in the context of a synchronized(Application.getEventLock()) block; same result.


In any case, it sort of works--it displays my UI fine. But almost immediately thereafter, the simulator (not my app) looks like it generates a data receive and then a send, and shows the little up/down arrows on the UI. As a result, this whites out the display UI. If I click the trackball, my app repaints, mostly (minus one separator). I'm presuming the interrupting UI has higher priority.

How do I ensure that my app stays in the foreground, or at least repaints after being obscured?


I tried implementing the following in my MainScreen subclass: 


protected void onObscured(){
// Screen activeScreen = UiApplication.getUiApplication().getActiveScreen();
// activeScreen.getUiEngine().suspendPainting(true);


... both with and without the commented-out code, but neither had any visible effect.


Many thanks for any recommendations!



BlackBerry Development Advisor
Posts: 15,852
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: pushGlobalScreen repaint?

The repaint should occur automatically.  But I think you may be trying to display your GUI before the BlackBerry is prepared to do so.  Please ensure that you check the ApplicationManager.inStartup method to ensure that the startup process is complete before you display your GUI.


If this isn't the case, please post a larger code sample that shows how you are displaying the screen.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Developer
Posts: 2
Registered: ‎07-30-2008
My Device: Not Specified

Re: pushGlobalScreen repaint?

Greetings Mark,


Many thanks for the response! I tried putting in a sleep loop (first outside, then within the invokeLater), but that hung.


So, in response to your suggestion, I started stripping down the code to post as small an example as possible. In doing so, I discovered that I do not need to do a pushGlobalScreen. Instead, a simple pushScreen works as long as the MainScreen implements the method onObscured:



import net.rim.device.api.ui.*; public class AgentApp extends UiApplication { public static final long guidName = 0x7bad99728b25ff48L; public static void main(String args[]) { AgentApp app = new AgentApp(); app.execute(); app.enterEventDispatcher(); } private void execute() { invokeLater(new Runnable() { public void run() { pushScreen(new TestApp()); } }); } } import net.rim.device.api.system.*; import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; public class TestApp extends MainScreen { public TestApp() { // ... } protected void onObscured() { UiApplication.getApplication().requestForeground(); } // ... }

Thanks again,