Dialog.D_YES_NO

I use the following code

D = new dialog box dialog box (Dialog.D_YES_NO, "do you want to change your password", Dialog.YES, null, FOCUSABLE).
d.doModal ();
d.setChangeListener (this);

I want to do a task when you press the Yes button on this dialog box. Can any body guide me how to do this

Hello

Try this... Probably, it will help...

 int response = Dialog.ask(Dialog.D_YES_NO, "Do u want to change your password??");

 if(response == Dialog.YES){    

  //Your Event on Yes
} 

Tags: BlackBerry Developers

Similar Questions

  • Dialog.ask () do not work?

    Hi all

    I called Dialog.ask (Dialog.D_YES_NO, "text") in class A that extern class Thread.

    I debuged and he ran on this line but the dialog box occur and my program is suspended.

    but Dialog.ask (Dialog.D_YES_NO, "text") work well when she called in the class screen extern class.

    No matter what suggesstion, thank you!

    I think that you must synchronize the lock of the event when calling Dialog.ask

    public class A extends Thread{
        public void run(){
            ...
            synchronized(UiApplication.getEventLock()){
                 Dialog.ask(...);
            }
            ...
        }
    
    }
    
  • View dialog box in greek

    Hello

    How to display the dialog box in Greek, as well as Dialog.No of Dialog.YES & appears as in Greek and not in English?

    RET = Dialog.ask (Dialog.D_YES_NO, "Are you sure?", Dialog.YES)

    Thank you

    If you mean the button labels. You must use this kind of code:

    Dialog d = new Dialog(messages.getString(MY_QUESTION), new Object[]{messages.getString(YES), messages.getString(NO)}, new int[]{Dialog.YES, Dialog.NO}, Dialog.YES, Bitmap.getPredefinedBitmap(Bitmap.QUESTION));
    

    It requires small changes to compile.

  • Problem with dismissing the dialog box

    Hello world

    This is my first post here. Sorry if the question is very simple...

    I need to download an image on server. I display a dialog box to confirm if the file should be downloaded.

    Everything works well except that the dialog box is dismissed after that the whole process is over. I know I'm missing something-related threads. pls help me to understand.

    Here is my code:

    public void fieldChanged(Field f, int context) {
        if (f == addButton) {
                        FileSelectorPopupScreen fps = new   FileSelectorPopupScreen();
            fps.pickFile();
            theFile = fps.getFile();
    
            if (theFile == null) {
                Dialog.alert("Screen was dismissed.  No file was selected.");
            }
            else {
                UiApplication.getUiApplication().invokeAndWait (new  Runnable(){
                public void run(){
                    int confirmationResult = Dialog.ask(Dialog.D_YES_NO, "Do you                    want to upload?", Dialog.YES);
                    if (confirmationResult==Dialog.YES) {
                             status=1;
                    } else {
                             status=0;
                    }
                }
              });
    
            }
    
            if(status==1){
                Thread t= new Thread(){
                    public void run(){
                        //MY CALL TO WEBSERVICE                     }
                }};
    
                try{
                    t.start();
                    t.join();                                           refreshData(); //call to method to post the image data to server                        //and refresh the screen with new image
                }
                catch(Exception e){
    
                }
    
                }
            }
    
        }
    

    My problem is that the I selected YES the dialog box only after the call to webservice licensees are completed and the image is published on the server and the screen is refreshed with the new image.

    Let me know what I'm missing.

    Welcome to the forum!

    Correctly, you start the process of network on a separate Thread.  Then you attach the wire event for this Thread by using the following instructions:

    t.Start ();
    t.Join ();

    So you give up the thread of events not until your networking activity has finished.  It does not block your event feed so that your application will become unresponsive to the user and as you noted, activities requiring feed event, such as the removal of your dialog box, cannot occur.

    You must reprogram your treatment so that the activity of the network as a completely asynchronous operation.  You can't wait on this.  You should get to tell you when it has finished.  I suggest that looking at the observer model during the implementation of this process.

  • Taking a problem of dialog yes answer - no

    Hi, I have a problem with my dialog box. Long story short, this dialog box will be displayed at one time even to the homescreen (so it will come out the same, the application is closed). Here's the code for the dialog box:

    {Synchronized (UiApplication.getEventLock ())}
    UI UiEngine is Ui.getUiEngine ();.
    Dial dialog = new dialog box (Dialog.D_YES_NO, "Detik.com Open feeds?"
    Dialog.YES,
    Bitmap.getPredefinedBitmap (Bitmap.QUESTION),
    Manager.VERTICAL_SCROLL);
    ui.pushGlobalScreen (dial, 1, UiEngine.GLOBAL_QUEUE);

    int answer = ((Dialog) dial) .getSelectedValue ();
    If (response == Dialog.YES) {}
    Feeds();
    }
    }
    }

    Now, I want the application to push a new screen whenever the 'yes' is selected. But it does not work. Can someone help me?

    Currently, you push as a queued object dialog box and immediately ask him for his status. you would need a very quick for this user

    Push the screen with http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/ui/UiEngine.html#GLOBAL_MODAL let block code, you can get the result when he returned.

  • Yes/No dialog

    I took a peek in the Java BlackBerry Developer documentation, but I have seen no mention on how to create a Yes / No dialog box. Could someone point me in the right direction?

    Must have been a very brief look.

    See the documentation for the API for the "Dialogue".

    RET = Dialog.ask (Dialog.D_YES_NO, "Are you sure?", Dialog.YES)

  • Problem with custom dialog box

    I have a custom dialog box. The code goes here

    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    import net.rim.device.api.ui.decor.BackgroundFactory;
    
    public class CustomDialog extends Dialog{
    
        public CustomDialog(int command,String msg,int color,int alpha){
             super(command, msg, command,Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), VerticalFieldManager.FOCUSABLE);
             setBackground (BackgroundFactory.createSolidTransparentBackground (color, alpha));
        }
    
    }
    

    I'm the caller to another class as follows

    CustomDialog d = new CustomDialog(Utils.D_YES_NO,"Do you want to exit",Color.BLUE,140);
    d.show();
    

    Its display very well and as I intended it to be. But the problem is that I'm not able to get the index of the choice to perform certain actions, such as

        int i=d.getSelectedValue();
    
                        if(i==Dialog.D_YES){
                            Dialog.alert("hi");
                        }
    
                        }
    

    Its do not call the dialog box, can anyone suggest me how to get the index of the choice that I chose to say YES or NO and to perform tasks accordingly

    Plese try suite

    CustomDialog d = new CustomDialog(Dialog.D_YES_NO,"Do you want to exit",Color.BLUE,140);
                    d.show();
                    d.setDialogClosedListener(new DialogClosedListener() {
    
                        public void dialogClosed(Dialog dialog, int choice) {
                            /*
                             *   // Field descriptor #211 I
                                  public static final int YES = 4;
    
                                  // Field descriptor #211 I
                                  public static final int NO = -1;
                             */
                            int i=choice;
                            System.out.print("Selected Value :"+choice);
                            if(Dialog.YES==choice){
                                System.out.println("Selected Value : YES");
                            }else if(Dialog.NO==choice){
                                System.out.println("Selected Value: NO");
                            }
    
                        }
                    });
    

    If it is useful, please make as response and do not hesitate on LIKE button thanks

  • Dialog API doesn't return a value on DevAlpha

    Hi, Im implementation of customAskAsync with the D_YES_NO button. I'm warning index in dialogCallBack (index) or not click on the dialog box. When I test with ripple on Chrome, I get the correct values. When I package and test on DevAlpha, I don't get all the values returned. In the alert, all I get is [object Object], which is returned? I simplified the code below.

    function confirmationDialogPurge(message, dialogTitle) {
        try {
            blackberry.ui.dialog.standardAskAsync(message,
                blackberry.ui.dialog.D_YES_NO, confirmationPurgeTable, {
                title : dialogTitle,
                size : blackberry.ui.dialog.SIZE_LARGE,
                position : blackberry.ui.dialog.CENTER
            });
        } catch (e) {
            alert("Exception in standardDialog: " + e);
        }
    }
    function confirmationPurgeTable(index){
        alert(index);
    }
    

    Sorry, I'm wrong.

    It works, BUT it returns an object.

    Object {return: "Yes"}
    

    So, you'll want to use something like this in your callback function

    function confirmationPurgeTable(index){
       var button = index.return;
    }
    
  • Need help Dialog.Ask

    Hello

    How can I get the value of the button clicked the dialog.ask that I tried with the following code, but it is retruning-1.

    Here is the code I tried

    result int = Dialog.ask (Dialog.D_YES_NO, "you do not have an open account, you want to create a?");    . Can someone help me with the code snippet.

    Thank you

    Sujithravindran

    follow these steps:

    Dialog d = new Dialog(Dialog.D_YES_NO,
                            "You don't have an Account open, would you like to create one?",
                            1,
                            null,
                            Manager.USE_ALL_WIDTH);
                    int i = d.doModal();
    
                    if (i == Dialog .YES)
                    {
                        //do something positive ehre
                    }
                    else
                    {
                           //do something ehre
                    }
    
  • Set the default choice in the dialog box

    Dialog.ask (Dialog.D_YES_NO, "Change information");

    How to set the default choce on no:

    Dialog.setDefault (?);

    Dialog.ask (Dialog.D_YES_NO, "Change information", Dialog.NO);

  • Retrieve the value of Dialog.ask

    I am trying to write a function that will create a context menu using Dialog.ask and return the result of the dialog box to the calling Thread.  So far I have somethings like this:

    //display a pop-up "Yes or No" box and return true for yes, false for no
    public boolean ask(final String question){
        UiApplication.getUiApplication().invokeLater (new Runnable(){
                                                          public void run(){
                                                              int answer = Dialog.ask(Dialog.D_YES_NO, question, Dialog.NO);
                                                              if(answer == Dialog.YES){
                                                                  //somehow return true                                                          }
                                                              else{
                                                                  //somehow return false                                                          }
                                                       }});
    }
    

    I've seen a similar thread, but I didn't know how to use the solution.

    http://supportforums.BlackBerry.com/T5/Java-development/getting-values-back-from-runnable-dialog-ask...

    In short, how to use DialogClosedListener to retrieve the value of Dialog.ask to ?

    First of all, you probably want to use invokeAndWait so that the calling thread is blocked until the Runnable.run () ends. After that, one solution is to store the result of somewhere. For example, the subclass of the floor and add a field where you store the value (a more general concept of an executable that can return a value in J2SE is the future, but it is not available out of the box in J2ME). Once completed invokeAndWait, you can read this field. Alternatively, you may return the value by changing something in the outer class (one that contstructs the Runnable). For example,.

    final int[] result = new int[1];
    UiApplication.getUiApplication().invokeAndWait(new Runnable() {
      public void run() {
        result[0] = Dialog.ask(...);
      }
    });
    
    int choice = result[0];
    ...
    
  • Does anyone know how to change the culmination of auto from 'no' to 'yes' in dialog.ask?

    No big deal here, I want to just my 'Yes' button, highlighted initially instead of the 'no' in the dialog.ask function. Anyone know how to change it? Thank you!

    Something like that?

    int choice = Dialog.ask (Dialog.D_YES_NO, "You want to stop downloading?", Dialog.NO);

  • Result of the dialog box

    Hello

    I have a background application that listens to a webservice and informs the user if he has a new message.

    I use the following code:

    UI UiEngine is Ui.getUiEngine ();.

    Dialog dlg = new dialog box (Dialog.D_YES_NO, "you have a new Message...

    ui.pushGlobalScreen (dlg, 1, UiEngine.GLOBAL_QUEUE);

    The problem is, I want to show this dialog only once (now the dialogues are overlapping when several messages in a short time)!  and (of course) I want to perform different actions for YES/No. How can I get the result of the dialog box, because I can't use

    int result = Dialog.ask (.);

    Find anything useful on the web, so any ideas?

    Greetings

    Dominik

    dlg.setDialogClosedListener () takes care of these two questions: dialogClosed() both marks the time (you can notice some synchronization object, for example) and gets the choice as a parameter index.

    Good luck!

  • Dialog box erases the part of the screen at the end

    Hi all

    I'm having a problem using the curve 8830 Simulator and JDE 4.2.1 when you close the dialog boxes. When I close a message of dialogue in my application to the fence, the dialog box clears a rectangle of the screen that is proportional to the size of the dialog box. In other words, if I drew pictures in the background bitmap, they are deleted (and I think that fields are left unaffected). This seems to occur only with the help of the 8830 and does not occur when you use, say, the 8520 Simulator (which has a more recent OS). There are possible solutions to this problem? Thanks in advance!

    I'm basically calls the help dialog box:

    for example...

    int response = Dialog.ask (Dialog.D_YES_NO, "do you think the screen to clear the background", Dialog.YES);

    if(Response == Dialog.no) {}
    ...
    } else {}

    ...

    }

    It is by reading a similar thread, give to think it can help, "If you do not pushModal() with the GLOBAL flag is set, then please try this first.", but there is no clear example of implementing exactly this...

    Thanks again

    Detect the onFocus() or onExposed() event in your screen and you call invalidate().

    This will precipitate paint this over.

  • View dialog box on powerUp()

    Hello

    I am building an app that does not have a graphical user interface and runs in the background. The application uses PhoneListener to interrupt a call and create a new one in its place. Since I have no GUI I cannot send the keystrokes required to phone until after a dialog box is displayed (either a dialog box, asking permissions of the Application, or by changing the OptionsProvider). What I want to do, it's just pop up a dialog on startup so I can then inject my shots to end the call.

    Here is my code:

    public class GVIntercepter extends UiApplication implements SystemListener
    {
        public static void main(String[] args)
        {
            // register an options provider
            GVIntercepterOptionsProvider provider = new GVIntercepterOptionsProvider();
            OptionsManager.registerOptionsProvider(provider);
    
            // register a phone handler
            PhoneHandler phone_handler = new PhoneHandler();
            Phone.addPhoneListener(phone_handler);
    
            GVIntercepter instance = new GVIntercepter();
            // instance.enterEventDispatcher();
    
            if( ApplicationManager.getApplicationManager().inStartup() ) {
              // Add a system listener to detect when system is ready and available.
              instance.addSystemListener(instance);
            } else {
              // System is already ready and available so perform your start up work now.
              // Note that this work must be completed using invokeLater because the
              // application has not yet entered the event dispatcher.
              instance.doStartupWorkLater();
            }
            // Enter the event dispatcher.
            instance.enterEventDispatcher();
        }
    
        //Invoked when the user is putting the device into a power off state.
        public void powerOff()
        { }
    
        //Invoked when the device has left the power off state.
        public void powerUp()
        {
          Application.getApplication().removeSystemListener(this);
          doStartupWork();
        }
    
        //Invoked when the internal battery voltage falls below a critical level.
        public void batteryLow()
        { }
    
        //Invoked when the internal battery voltage has returned to normal.
        public void batteryGood()
        { }
    
        //Invoked when the internal battery state has changed.
        public void batteryStatusChange(int status)
        { }
    
        private void doStartupWork()
        {
          // Perform your start up activities here!
          Application.getApplication().invokeLater( new Runnable() {
            public void run() {
              Dialog.ask(Dialog.D_YES_NO, "Display?");
            }
          } );
        }
    
        private void doStartupWorkLater()
        {
          Application.getApplication().invokeLater( new Runnable() {
            public void run() {
              doStartupWork();
            }
          } );
        }
    
        public GVIntercepter()
        {    }
    }
    

    I tried almost everything to get the dialog box to display and I am at a loss here. Any ideas?

    Also, I'd be open to suggestions on power sending keystrokes to a background application in the phone app and use PhoneArguments to call without displaying any prompt at all.

    I never thought seriously about doing something like what you're trying to do, so I'm sorry this isn't a complete answer to your questions.  You may use these details to get a little further though.

    You say that your app is a bottom up, however you have extended UiApplication.  If your application is treated as it displays a screen of the user, but you never insert a screen, if your application never gets thrust in the foreground.  You will find that, once you started with your current code, your icon is available in the Task Switcher (ALT + ESC) and if you swap to your application, your dialog box is there to be seen (on a white background, as any UiApplication).  Try it and see.

    You can replace your code in doStartupWork() with something like the following, so that you can see actually started.  Try this and then see what happens when you select your application by using the Task Switcher after you answer your dialog box (note I use UiApplication rather than on request, simply because the code you call later should a UiApplication to run.  Your code works really because you have found your own application, which is currently spreading UiApplication.  If you change it to extend the Application instead, then you will get a UiApplication.

          UiApplication.getUiApplication().invokeLater( new Runnable() {
            public void run() {
                UiApplication.getUiApplication().requestForeground();
                Dialog.ask(Dialog.D_YES_NO, "Display?");
                UiApplication.getUiApplication().requestBackground();
            }
          } );
    

    I suspect that you really want to be a background application.  In this case, you extend Application rather than UiApplication.  Then, to bring something to the attention of the user, you can use UIEngine, as shown here:

    How - to alert a user to a background application
    Article number: DB-00407

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...

    Alternatively, you can do what you do, stick your phone earpiece in place, then the UiApplication, the output is not in the Task Switcher.   Even if you have left your UiApplication, your hook is still in place and can still do something.

    I have a point more than related.

    You are actually setting up an earpiece of phone.  When this listener is controlled, it will run the app phone, not your Application.  This application has a GUI, then maybe you need not to use this dialog box "to access a graphical interface.

    Sorry, as stated, I never really looked seriously to do something like what you do, then I do not understand everything and maybe you have this covered.  Bit I hope this helps.

Maybe you are looking for