BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 05-13-2005, 05:17 PM   #1
vcoleman
New Member
 
Join Date: May 2005
Model: 7290
Posts: 11
Default displaying screen from menuitem

Please Login to Remove!

I have an application loaded at startup that inserts a menuitem when messages are listed. When the menu item is selected it's supposed to display a screen derived from MainScreen, but nothing happens. I searched the forum for menuitem issues and source for bbcorrector was mentioned but I am unable to find the java; just binaries. If I load "MyScreen" from the constructor of an application that extends UiApplication it works. What is going on? Any thoughts? Any other way to do this? Once again my ultimate goal is to load a menuitem on startup and on selection takeover the screen. Thanks... The relevant code looks like this:

public final class TheApp extends UiApplication {
public static void main(String[] args) {
new TheApp().enterEventDispatcher();
}

public TheApp() {
super();
ApplicationMenuItemRepository amir =
ApplicationMenuItemRepository.getInstance();
amir.addMenuItem (ApplicationMenuItemRepository.MENUITEM_MESSAGE_LI ST,
new MyMenuItem());
}


private class MyScreen extends MainScreen {
//variables for the user interface
LabelField _title;

public MyScreen() {
super();//invoke MainScreen constructor
//define title of the app
_title = new LabelField("My Screen", LabelField.ELLIPSIS
| LabelField.USE_ALL_WIDTH);
setTitle(_title);
}

private class MyMenuItem extends ApplicationMenuItem {
MyMenuItem() {
super(20);
}

public String toString() {
return "Open My Screen";
}

public Object run(Object context) {
invokeLater(new Runnable()
{
public void run()
{
pushScreen(new MyScreen());
}
});

return null;
}
}
Offline  
Old 05-14-2005, 10:55 PM   #2
vcoleman
New Member
 
Join Date: May 2005
Model: 7290
Posts: 11
Default Non-functioning pushScreen problem dis-solved

After much frustration/experimentation it seems that the problem is that


pushScreen(...); // nothing happens

is not the same as

UiApplication.getUiApplication().pushScreen(...); // IT WORKS !

I used invokeLater(...) because the JDE reported : @2D480000 "UI engine accessed without holding the event lock.".

But it is not necessary to use invokeLater(...) so long as it's
UiApplication.getUiApplication().invokeLater(...)

It seems that the compile time UiApplication is not the same as the current runtime application.

In any case, a suggested cautious practice would be to explicity name your application objects in your code like this:

application.invokeLater(...);
application.pushScreen(...);

OR

UiApplication.getUiApplication().whatever(...)

unless you are quite sure

UiApplication.this == UiApplication.getUiApplication() such as during the app's construction...


Can anyone confirm or add to this explanation?
Offline  
Old 05-17-2005, 12:16 PM   #3
DoomBringer
Talking BlackBerry Encyclopedia
 
Join Date: Feb 2005
Model: 7280
Carrier: cingular, no wait, AT&T
Posts: 300
Default

You're confusing the two UiApplications here. You're extending UiApplication, so you get your own pushScreen function, which is fine. However, invoking that has nothing to do with the screen that is currently being displayed. Thus, to open your screen, you need to get the current UiApp, and push the screen onto the screen stack.
You're running into this issue because you're a menu entry. If you were a normal app, you could call your own pushScreen function, because then you would be the current UiApp being shown to the user.
Did that make sense?
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Implement Whisker Switch  picture

Implement Whisker Switch

$50.00



JCB BACKHOE - GENUINE JCB IGNITION SWITCH AND 2 KEYS (PART# 701/80184 701/45500) picture

JCB BACKHOE - GENUINE JCB IGNITION SWITCH AND 2 KEYS (PART# 701/80184 701/45500)

$39.90



Dusk to Dwan/Day Night Sensor, Photoelectric Switch, Photo Cell Sensor 110-277V picture

Dusk to Dwan/Day Night Sensor, Photoelectric Switch, Photo Cell Sensor 110-277V

$49.28



NS1-63-NA. EATON /Moeller breaker  MAIN SWITCH  63 AMPS picture

NS1-63-NA. EATON /Moeller breaker MAIN SWITCH 63 AMPS

$375.00



Commercial Air Curtain 36

Commercial Air Curtain 36" Silent Speed Adjustable 2 Limit Switch UL Certified

$121.77



ELECTRIC COOLING FAN GROUND-ING THERMO-STAT SWITCH RADIATOR TEMP-ERATURE SENSOR picture

ELECTRIC COOLING FAN GROUND-ING THERMO-STAT SWITCH RADIATOR TEMP-ERATURE SENSOR

$21.95







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.