BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 10-27-2008, 03:23 PM   #1 (permalink)
New Member
 
Join Date: Oct 2008
Model: 8800
PIN: N/A
Carrier: Alltel
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Simple Dialogs throwing exception: pushModalScreen called by a non-event thread

Please Login to Remove!

I'm new to BB GUI development.

I'm trying to call something as simple as:

Code:
Dialog.alert("Alert!");
as soon as my application starts, from within a main screen that I've defined.

My setup is:

I have an App defined:

Code:
public class MyApp extends UiApplication {
    MyModel m_model;  // Is the data model
    MyView  m_view;    // Acts as both the view and controller.
                            
    public static void main(String[] args) {
        MyApp theApp = new MyApp();
        theApp.enterEventDispatcher();
    }
    
    // App ctor
    public MyApp() {
        // create model first so it can init before the view asks it for values
        m_model = MyModel.getInstance(); // singleton
        m_view = new MyView();
        
        // show the main screen.
        pushScreen(m_view);
    }
}
And the MainScreen/View (I've removed much to simplify):

Code:
final class MyView extends MainScreen implements MyResource {
    private MyModel m_model;
    private ResourceBundle _resources = ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME);
    
    public MyView() {
        super();
        m_model = MyModel.getInstance();

        // ... Init components
        LabelField title = new LabelField(_resources.getString(APPLICATION_TITLE), LabelField.ELLIPSIS
        | LabelField.USE_ALL_WIDTH);
        setTitle(title);

        Dialog.alert("Alert!");
    }
    
    protected void onDisplay()
    {
        Dialog.alert("Alert!");
    }
}
I've tried to call Dialog.alert() from both the constructor and the onDisplay method with the same result.

I get this exception:

"pushModalScreen called by a non-event thread"

Thanks

Last edited by jrlawhorne : 10-27-2008 at 03:46 PM.
Offline  
Old 10-27-2008, 03:41 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

1) m_view is defined as MyView but instantiated as ToodledoView.

2) Following your code, your application has not yet entered the event dispatcher when you are calling the Dialog in the MyView constructor.

I guess you should escribe what it is that you are trying to accomplish. I've never tried to pop a modal dialog in the "onDisplay()" method before, obviuosly the system doesn't like it.
Offline  
Old 10-27-2008, 03:49 PM   #3 (permalink)
New Member
 
Join Date: Oct 2008
Model: 8800
PIN: N/A
Carrier: Alltel
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

1) typo - This code is a simplified extract.
2) When my app starts up, I need to check it's configuration and get input from the user if the app has never been run before, for instance. There are other things that get checked but that's just one of them.

So, eventually, I'll need a more complicated dialog/screen to come up, conditionally, to gather this information. I'm using Dialog.alert() because it's simple and shows the same problem.
Offline  
Closed Thread


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Premium Elbow Length Gloves for Thorns, Rose Gloves, Cactus Gloves, Blackberry
$22.89
Premium Elbow Length Gloves for Thorns, Rose Gloves, Cactus Gloves, Blackberry pictureLot of 5 Nextel Blackberry 7520 and 1 7510 - For Parts - Accessories Included
$29.95
Lot of 5 Nextel Blackberry 7520 and 1 7510 - For Parts - Accessories Included pictureLot of 14 Blackberry 9650 Verizon Smartphone (As-Is)
$100.0
Lot of 14 Blackberry 9650 Verizon Smartphone (As-Is) pictureBlackBerry Unlock Code AT&T USA Blackberry Curve 8320 8520 Clean imei only
$1.99
BlackBerry Unlock Code AT&T USA Blackberry Curve 8320 8520 Clean imei only pictureBlackBerry Unlock Code AT&T USA Blackberry STL100 3 Clean imei only
$20.0
BlackBerry Unlock Code AT&T USA Blackberry STL100 3 Clean imei only picture






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