07-30-2008 11:26 PM
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);
UiApplication.getApplication().requestForeground();
}
... both with and without the commented-out code, but neither had any visible effect.
Many thanks for any recommendations!
Jeff
Solved! Go to Solution.
07-31-2008 11:20 AM
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.
08-01-2008 12:08 AM
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,
Jeff