BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-17-2008, 10:23 AM   #1 (permalink)
New Member
 
Join Date: Jun 2008
Model: 8120
PIN: N/A
Carrier: Entel PCS
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
New Member
 
Join Date: Jun 2008
Model: 8120
PIN: N/A
Carrier: Entel PCS
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
New Member
 
Join Date: Jun 2008
Model: 8120
PIN: N/A
Carrier: Entel PCS
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
New Member
 
Join Date: Jun 2008
Model: 8120
PIN: N/A
Carrier: Entel PCS
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

yeap
Offline  
Old 07-21-2008, 02:21 AM   #9 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
New Member
 
Join Date: Jun 2008
Model: 8120
PIN: N/A
Carrier: Entel PCS
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
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


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

(5PCS) BR24C02-RMN6TP IC EEPROM 2KBIT 100KHZ 8SOIC 24C02 BR24C02
$5.48
(5PCS) BR24C02-RMN6TP IC EEPROM 2KBIT 100KHZ 8SOIC 24C02 BR24C02 picture(5PCS) BR93L66RFVT-WE2 IC EEPROM 4KBIT 2MHZ TSSOP-B8 93L66 BR93L66
$8.06
(5PCS) BR93L66RFVT-WE2 IC EEPROM 4KBIT 2MHZ TSSOP-B8 93L66 BR93L66 picture(5PCS) BR24T08FVT-WE2 IC EEPROM I2C 8K 400KHZ 8-TSSOP 24T08 BR24T08
$3.48
(5PCS) BR24T08FVT-WE2 IC EEPROM I2C 8K 400KHZ 8-TSSOP 24T08 BR24T08 picture(5PCS) 25AA320AT-I/MNY IC EEPROM 32KBIT 10MHZ 8TDFN 25AA320AT-I 25AA320 25AA320A
$7.56
(5PCS) 25AA320AT-I/MNY IC EEPROM 32KBIT 10MHZ 8TDFN 25AA320AT-I 25AA320 25AA320A picture(5PCS) AT93C66B-SSHM-B IC EEPROM 4KBIT 2MHZ 8SOIC 93C66 AT93C66
$6.15
(5PCS) AT93C66B-SSHM-B IC EEPROM 4KBIT 2MHZ 8SOIC 93C66 AT93C66 picture






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