BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 07-17-2008, 10:23 AM   #1
maixtor
New Member
 
Join Date: Jun 2008
Model: 8120
PIN: N/A
Carrier: Entel PCS
Posts: 14
Post Background Thread launching a Dialog Box

Please Login to Remove!

Hello:

I have a thread running in background dedicated to manage data over http connections. There is someway to show a Dialog Box in HomeScreen from my thread ?

Thanks in advance.
Offline  
Old 07-17-2008, 10:31 AM   #2
Ivanov
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Default

Code:
    // Get an instance of the UiEngine and place a Dialog in the queue
    // to alert the user of the message in the String data.
    public static void showMessage(String message)
    {
        StringBuffer sb = new StringBuffer("MyApp:");
        sb.append(":\n");
        sb.append(message);

        Dialog dialog = new Dialog( Dialog.D_OK, sb.toString(), Dialog.OK,
                             Bitmap.getPredefinedBitmap(Bitmap.INFORMATION),
                             Manager.VERTICAL_SCROLL);        
        synchronized(Application.getEventLock())
        {
            Ui.getUiEngine().pushGlobalScreen(dialog, 1, UiEngine.GLOBAL_QUEUE);
        }
    }
change UiEngine.GLOBAL_QUEUE to UiEngine.GLOBAL_MODAL and the dialog will block your thread until its closed
Offline  
Old 07-17-2008, 11:00 AM   #3
maixtor
New Member
 
Join Date: Jun 2008
Model: 8120
PIN: N/A
Carrier: Entel PCS
Posts: 14
Default

Thanks, buts there is any way to avoid losing the contents of the background of the screen ?. The actual code replaces the contents of the background with white pixels.

Thanks.
Offline  
Old 07-17-2008, 02:54 PM   #4
maixtor
New Member
 
Join Date: Jun 2008
Model: 8120
PIN: N/A
Carrier: Entel PCS
Posts: 14
Default

Hello:

When I try the code above, I got:

"java.lang.IllegalStateException: no application instance"

I think that someting is missing.

Thanks
Offline  
Old 07-18-2008, 06:01 AM   #5
Ivanov
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Default

from where are you calling the code?
The behaviour with white background I also mentioned with PopupScreens. Dialogs should work. Also if your application is extending UiApplication you can use

UiApplication.getUiApplication().pushScreen(dialog );

instead of

Ui.getUiEngine().pushGlobalScreen(dialog, 1, UiEngine.GLOBAL_QUEUE);
Offline  
Old 07-18-2008, 04:18 PM   #6
maixtor
New Member
 
Join Date: Jun 2008
Model: 8120
PIN: N/A
Carrier: Entel PCS
Posts: 14
Default

I was calling the code from a Thread Class without a Application instance o UiApplication Instance.
Offline  
Old 07-18-2008, 05:15 PM   #7
Ivanov
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Default

but how is this Thread created? During boot-up directly in the main()?
Offline  
Old 07-21-2008, 12:34 AM   #8
maixtor
New Member
 
Join Date: Jun 2008
Model: 8120
PIN: N/A
Carrier: Entel PCS
Posts: 14
Default

yeap
Offline  
Old 07-21-2008, 02:21 AM   #9
Ivanov
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Default

I think that might be the problem. Your thread is not associated with any UiEngine implementations.

I suggest you extend the Application class and start your thread from there.

Last edited by Ivanov; 07-21-2008 at 02:37 AM..
Offline  
Old 07-21-2008, 11:14 AM   #10
maixtor
New Member
 
Join Date: Jun 2008
Model: 8120
PIN: N/A
Carrier: Entel PCS
Posts: 14
Default

Thanks Ivanov, I've extend my application (Thread) from a Application class as you said and the problem as been fixed.

Thanks a lot !
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


30 Server/Guest Pager Restaurant Paging System Kit by LRS Long Range Systems picture

30 Server/Guest Pager Restaurant Paging System Kit by LRS Long Range Systems

$299.99



USA Windows VPS RDP Server/ Windows VPS Hosting - 4GB RAM + 150GB HDD picture

USA Windows VPS RDP Server/ Windows VPS Hosting - 4GB RAM + 150GB HDD

$11.99



Wti Console Server + PDU CPM-800-1-EA picture

Wti Console Server + PDU CPM-800-1-EA

$550.00



Server SE-SS 07020 Server Express Single Drop-In - NEW - COMPLETE - Genuine OEM picture

Server SE-SS 07020 Server Express Single Drop-In - NEW - COMPLETE - Genuine OEM

$180.00



Hubbell NXBTC NX Bluetooth Radio Module with Time Server -  picture

Hubbell NXBTC NX Bluetooth Radio Module with Time Server -

$129.99



Vollrath 72050 Cayenne 28 3/4

Vollrath 72050 Cayenne 28 3/4" x 13 3/4" Heat 'n Serve 4/3 Size Countertop Food

$285.00







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