BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 09-18-2007, 07:06 AM   #1
pa4o85
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Default Get rid of dialog?

Please Login to Remove!

I have a dialog like this opened:
Code:
int cancel = Dialog.ask("synchronizing...", new String[] {"Cancel"}, new int  []   {Dialog.CANCEL}, Dialog.CANCEL);
When the "Cancel" button of the dialog is clicked everything is ok, but when it is not clicked I would like to move the dialog out of my application. How can i get that?
Offline  
Old 09-19-2007, 08:37 AM   #2
Pook
New Member
 
Join Date: Sep 2007
Model: 7100
PIN: N/A
Carrier: Vodafone
Posts: 10
Default

In theory you should be able to create an instance of Dialog:

Code:
Dialog dialog = new Dialog( "synchronising...", new String[] { "Cancel" }, new int[] { Dialog.CANCEL }, Dialog.CANCEL, Bitmap.getPredefinedBitmap(0) );
dialog.doModal();
and then use the .close() or .cancel() method to dismiss it but when I simulate some external event by passing the dialog to another thread and invoking either method I get:

Code:
java.lang.IllegalStateException
Offline  
Old 09-19-2007, 09:49 AM   #3
pa4o85
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Default

Hi, I tried that idea. I make my own dialog box and push it to the display, like this:
Code:
cancelDialog = new CancelDialog("synchronizing...", new String[] {"Cancel"},
        new int[] {Dialog.CANCEL}, Dialog.CANCEL, Bitmap.getPredefinedBitmap(Bitmap.INFORMATION));
    UiApplication.getUiApplication().pushGlobalScreen(cancelDialog, 0, UiEngine.GLOBAL_MODAL);
..but when I want to close it, nothing happens, doesn't throw an exception even. I used several ways to close it.

1)
Code:
    cancelDialog.cancel();
    cancelDialog.close();
    UiApplication.getUiApplication().repaint();
2)
Code:
    UiApplication.getUiApplication().popScreen(cancelDialog);
...or something like this. I have no idea what is wrong.
Offline  
Old 09-24-2007, 01:41 AM   #4
Skipper_Joe
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Default

1) You need to close Dialog from another thread, since doModal() or ask() methods block current thread.

2) Since you close dialog from outside UI event-handling thread, you need to use something like this:
Code:
_uiApplication.invokeLater(new Runnable()
{
    public void run()
    {
        _dialog.close();
    }
});
Offline  
Old 09-24-2007, 03:35 AM   #5
pa4o85
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Default

Code:
    cancelDialog = new CancelDialog("Synchronizing...", new String[] {"Cancel"},
        new int[] {Dialog.CANCEL}, Dialog.CANCEL, Bitmap.getPredefinedBitmap(Bitmap.INFORMATION));
    UiApplication.getUiApplication().pushModalScreen(cancelDialog);
......and trying to close it
Code:
UiApplication.getUiApplication().invokeLater(new Runnable(){
            public void run() {
              cancelDialog.cancel();
              cancelDialog.close();
              updateLayout();
            }
          });
Well it is not working that way , but thank you for the advice!
Offline  
Old 09-24-2007, 05:45 AM   #6
Skipper_Joe
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Default

Do you call second piece - with invokeLater() - from other thread?
Offline  
Old 09-24-2007, 09:44 AM   #7
pa4o85
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Default

I called these two pieces in the main thread. Firstly I have opened the dialog, then started another thread (it makes some things) and at the end i closed the second thread and i wanted to close the dialog box that is displayed to the screen while the second thread is working. At the end of the second thread I am again in the main thread and want to close the dialog programatically, not as clicking the trackwheel.
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


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



DELL PowerEdge R310 Server picture

DELL PowerEdge R310 Server

$80.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



USED Moxa NPort5610-16 16-port RS-232 Serial Communication Server picture

USED Moxa NPort5610-16 16-port RS-232 Serial Communication Server

$284.58



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

$199.99







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