Use Dialog.ask to call message (email/sms)

Hello

I try to use Dialog.ask to ask the user to send information by e-mail or sms... I use the following code:

public void ask(){

      UiApplication.getUiApplication().invokeLater(new Runnable(){          public void run(){

              Object[] choices = new Object[] {"Email", "SMS",};                int result = Dialog.ask("Send Via:", choices, 1);

               switch (result) {             case 1:               email();              case 2:               sms();                    }};       });   }

When I use the dialog box displayed correctly, however when I choose either by e-mail or sms nothing happens...

I'm fairly new to java and mobile development so easy on me... I'm sure it's a simple solution.

I have searched these forums and tried a few different things, cant just make it work the way I need to.

Incase anyone wants to see these:

public void email(){      MessageArguments messageArgs = new MessageArguments(MessageArguments.ARG_NEW, "","", messageField.getText());        Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, messageArgs);   }

    public void sms(){        MessageArguments messageArgs = new MessageArguments(MessageArguments.ARG_NEW_SMS);        Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, messageArgs);        

    } 

Thank you so much for your support and your help

Thanks for the suggestion of using the breaks.  I have inserted two breaks and I'm still questions... See code below.  Again, any suggestions are welcome!

public void ask(){

      UiApplication.getUiApplication().invokeLater(new Runnable(){          public void run(){

              Object[] choices = new Object[] {"SMS", "Email"};             int result = Dialog.ask("Send Via:", choices, 1);

               switch (result) {             case 1:                   sms();                    break;                case 2:                   email();                  break;            }};       });   }

In doing so, the top option, SMS, still does not.  The button at the bottom, email, will work as it should

Tags: BlackBerry Developers

Similar Questions

  • 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];
    ...
    
  • Call Dialog.ask in the Thread Run method

    "in I want to call Dialog.alert and using following code but its exception to throw the wire.

    "Exception occurs java.lang.RuntimeException: pushModalScreen called by a thread of non-event."

    synchronized (Application.getEventLock ())

    {

    if (Dialog.ask ("catalog is obsolete. You want to keep it? ", choices, select, select [0])(==1)"

    {

    Run the required functionality

    }

    }

    pls help me

    I keep saying this, so forgive me of repeating myself, but:

    synchronized (Application.getEventLock ()) {}

    should only be used when nothing else will work for you or you make a very simple, very fast UI update.

    A Dialog.ask is not very fast!

    In this case, you have several options, but the most obvious solution is to ask the question before starting the Thread.  So, if that is your treatment

    Thread catUpdateThread = new Thread() {}

    public void run() {}

    Dialog.ask (...)

    Other treatments

    }

    }

    catUpdateThread.start ();

    What should do the same and works OK. :

    UiApplication.getUiApplication.invokelater (new Runnable() {}

    public void run() {}

    Dialog.ask (...)

    If (result == Yes) {}

    Thread catUpdateThread =...;

    catUpdateThread... Start();

    }

    }

    });

  • I get a dialog asking me if I want to open or save a document in firefox, whenever I click on an email in outlook in windows; What can I do to fix this? Thank you.

    Question
    I get a dialog asking me if I want to open or save a document in firefox, whenever I click on an email in outlook in windows; What can I do to fix this? Thank you

    Is it through Outlook Web Access?

  • Windows email will not be printed and give this message "email error unexpected call to the method"

    Windows email will not be printed and give this message "email error unexpected call to the method"

    is there a solution for this?

    Yes, I uninstalled the upgrade to IE9 and rebooted and unfortunately I can print my email again! No more unexpected call to the method.  Check my IE and it's IE8.

    Problem solved!

    Thanks for the replies.
    Neal

  • Retrieve the values of the executable (Dialog.Ask)

    Hello world!

    I have a situation where I have to ask the user a question according to the status of a remote object (sent to a web service).  This operation is performed within a Thread, so I can't directly use the Dialog.Ask () because it translates into the exception "Engine UI consulted without holding the lock of the event".  I used this code sample to get the dialog to the user

            synchronized(UiApplication.getEventLock()) {            Runnable push = new Runnable() {
    
                    public void run() {                    Dialog.ask(message, choices, 0);                }
    
                };
    
                UiApplication.getUiApplication().invokeLater(push);        }
    

    This work is nice, but I can't retrieve the result... And because it's in a thread, I don't know how I could get it... Can someone help me with this one?

    Thank you!

    You usually use

    Synchronized (UiApplication.getEventLock ())

    or

    UiApplication.getUiApplication (.invokeLater)

    There's no value in using both at the same time.

    In this case, the Dialog.ask returns an int, that indicates the result.  The doc of the API:

    Returns:
    The selection of your choice (not the index) value, as must be returned by getSelectedValue(). For example, CANCEL, OK or DELETE are among the possible return values.

    Thus, you can code something like:

    int i = Dialog.ask (...);

    Treat the i then returned.

    Without doubt, you actually want to return the result in your calling Thread.  I don't know how "legal", it is, but you might be able to get away with:

    selectedChoice int = - 1;

    {Synchronized (UiApplication.getEventLock ())}
    selectedChoice = Dialog.ask (.);

    }

    If you can't do that, then look to split the treatment at the time of questions and using a DialogClosedListener to the decision of the user process.  I don't know there are other options, just of can't think right now.

  • What are the details of sending messages text/SMS from computer?

    I'm afraid that this question is a bit off topic, but I searched and searched and searched for information on how to send any text or SMS from my computer. I don't have a cell phone, but I am inclined to believe that I can send the text of my computer. I am particularly interested in sending text responses in places like surveys of Ed Schultz Show text. I do not understand how to address a message to send text. The Ed Schultz Show refers to a number ": 6222639", and an address "* address email is removed from the privacy *, then apply to the text an 'A' or a 'B'." I'm just confused. Please, someone give me a clue.

    Thank you in advance to give a useful answer and not a bad mood put down.

    You need a cellular service to send text messages,

    Your internet service provider is perhaps the best people to ask,

    Instant messages, SMS is a function of a Messenger service,

    Hotmail - outlook.com uses Skype,

    Gmail has its own technology,

    What email service do you use, yahoo...

  • Simulate the phone call & message

    Hi all

    I'm developing an application that uses the api and api messaging phone. and before putting it on the device, I want to

    Test it on Simulator... so can fake phone call on Simulator (incoming call) and one incoming message...

    right now use the 4.2.0... Please guide me is it possible and if yes how?

    Kind regards

    xtpl

    phone calls are easy, there is a point of menu clean on the Simulator.
    to get the mails that you must start the mail server Simulator (ESS), you can send yourself real emails, then.

  • Dialog.Ask

    How to use it

    public static int ask(String message,                      Object[] choices,                      int defaultChoice)
    

    any psudo code

        public void a(){
    
            UiApplication.getUiApplication().invokeLater(new Runnable(){
                public void run(){
    
                    Object[] choices = new Object[] {"cancel", "exit", "to background" };
                    int result = Dialog.ask("really quit?", choices, 1);
    
                    switch (result) {
                    case 1:
                    System.exit(0);
                    case 2:
                    UiApplication.getApplication().requestBackground();
                    }
                }});
        }
    
  • How to change the fonts used to display the list of emails on the homepage?

    Looking at my Inbox or other e-mail folder, the font used to display the list of emails in folders - gives me a headache.

    How can I change this font? Is there an add-on? Something in their profile?

    Ideally, I would like to change the background color of white also. (Perhaps the color on this page where I ask the question. "It's easy to read, the font and the color!)

    I've been a programmer in a past life, so I'm tech abreast. I am new to use Thunderbird (I used FF for several years.)

    Thank you!!

    Yes, to change the font, you can use this addon:

    Also, try to use themes:

  • Firefox tabs used to ask me if I wanted to save tabs, but now he just asks me if I want to close, just a warning, but no option to save, Firefox 3.6

    Firefox used to ask me if I wanted to save tabs, but now he just asks me if I want to close tabs, just a warning, but no option to save, I searched on the problem, but it appears to the user of firefox 4 and I am still using firefox 3.6 and do not want to upgrade at this time

    Hi seraphim99,

    You will get this Quit Firefox message "do you want to save your tabs for the next time it starts? [Save and exit] [Quit] [Cancel] If you follow what is currently step 31 in the link I provided restoration of a lost session tabs (#tabslost)

    Which indicates as follows: (the bold is set of users)

    • browser.showQuitWarning user value Boolean true
    • Boolean true default browser.tabs.warnOnClose
    • Boolean true default browser.warnOnQuit
    • browser.warnOnRestart user value Boolean true

    Links have been included it helps with topic: config for those who know not how to change the configuration variables, as well as an extra for this reference and as well as other similar issues to make Firefox 4 look/act like Firefox 3.6.17 would also responded in particular items in the first 10 steps in the same area. Which was addressed by the following part of my first answer

    You can make Firefox 4.0.1 resemble Firefox 3.6.17, paragraphs numbered 1 to 10 in the next topic ["http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface difficulty Firefox 4.0 UI toolbar, problems (make Firefox 4.0 look like 3.6)"].

    I don't know if you looked at the page web or not, but I've highlighted a few additional words there to try to make the Web page in a clearer future to others.

    Hope that helps

  • Skype won't let me call, message, or I want to change my online status

    Hello all, I have several problems on my Skype. I use Skype on Windows 8. I had these problems once or twice and I fixed it usually simply by deleting the program and it redownloading. I had the question once again and I'm not for most everything to remedy, but nothing works. The issue or the problem im having is pretty simple, I can't CALL, MESSAGE, or the STATE of MY CHANGE. Whenever I message someone something it simply never sends and the loading thing keeps circuling around and around and never sends. When I send a picture tell the truth, it is 'impossible to download/send. When I try call call never rings and just stays there forever and I can't put end. usually, I have to restart my Skype out. The latest issue is change my status. Usually, when I change my status the program does nothing. Basically, those are my questions for my Skype. I've seen other people having the same issue. Some people helping gave them some tips. I followed the steps to solve the problem. I tried first by la - press the key Windows and R and type in %AppData%. He said renaming the folder Skype 'Old_Skype '. I did, but unfortunately another problem occurred. HE says that you cannot rename this file is open in another program/place I do not know where because I already closed my Skype and quit out of it. The second thing I did was-press the Windows key and press R and type in % temp%/skype. Then I had to remove a folder called 'DbTemp '. The same problem still product - you cannot delete this file because the file is open in another program/place. I decided to rethink and to get the new Skype for windows. The initial problem was still there. I can't call or message or change my status on one of my Skype (Skype Desktop and Skype) modern Windows. I gave a thought and said if it was my computer. I denied that thought because my internet browser and the regular PC games still worked and operated very well. So I said what happens if it is just my Skype profile itself? I also countered this thought by the fact that I was still able to use Skype on my mobile phone. THIS ISSSUE IS REALLY A PAIN KILLER. I USE SKYPE TO COMMUNICATE WITH FRIENDS AND I CAN'T CONVINCE HIM TO USE ANOTHER PROGRAM INSTEAD OF SKYPE. AND MY DEVICE USING MOBILE WHILE PLAYING SOME PC GAMES ON MY COMPUTER MAKES MY GAMES LAG AND CRASHED. PLEASE I REQUEST ASSISTANCE AND HELP FROM ANYONE!

    http://www.howtogeek.com/107511/how-to-boot-into-safe-mode-on-Windows-8-the-easy-way/

  • Summary after call message balance or usage data

    I have lenovo s 820 it is not whose record after making a call, message or by using the data connection, how do I turn it on...

    try to install USSD to notification fm google game it solve my problem even in P780
    https://play.Google.com/store/apps/details?ID=com.Aeon.ussdtonotification

    of course restart handset after installation

  • I use AOL and I get no emails.

    original title: not receiving emails

    I use AOL and I get no emails.  Not sure if I was doing something.

    Hello

    ·          You receive an error message when accessing AOL mail?

    ·          Through browser you are trying to access AOl mail?

    ·          You are using a wired or wireless connection to connect to the internet?

    ·          What was the software or the hardware recent changes made to the system?

    ·          What operating system do you use?

    ·          Are you facing this problem only with AOL email?

    Example Windows 7 Professional 32-bit

    You can also mail AOL Contact support if the problem is specific to AOL

    http://help.AOL.com/help/product/aol_webmail/

    I hope this helps.

  • TB does not automatically download new messages email periodically even if "download automatically" is checked and set to 10 minutes

    TB does not automatically download new messages email periodically even if "download automatically" is checked and set to 10 minutes. Photo of the account server settings is attached.

    (For reference: it's POP, IMAP settings not.)

    Click the Advanced button under the settings above in the section "Message Storage" and review the when downloading mail on the server for this account, use the following folder to store new messages: settings.

    -Is selected Inbox for this account , and the record really / still exist? -If the second option (Inbox for the other account) is selected, make sure that the path is valid and that the box include this server when getting new messages is checked.

Maybe you are looking for

  • HP Photosmart B110: cannot install drivers, USB error message

    Hello! I'm stuck installing the software/drivers for my printer. I bought a new computer and everything worked fine until I tried to install the printer. I get this error message, and I can't move, so I can't use the printer This is a screenshot of t

  • the screen is black

    The display is black, but if hold power button for about 10 seconds, you will see the screen go completely black. So power is on but no pictures or text is displayed.

  • system tray icon

    How can I reduce a VI to an icon in the tray (7,8,8.1) Windows system?

  • Problem of DOS window.

    I have a system with Core 2 Duo processor with OS Windows Server Standard and 4 other monitors are attached using NComputing devices. The problem is that the command prompt is not running in Mode full screen. Is there a solution?

  • help with backup discs

    I just did a restore with recovery disks. I backed up things that I had to save. Well when I put the backup in the first discs worked a 2nd would not work. There is only the 2 discs. I am 71 and on income fixed and now I don't know what to do to get