Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 23
Registered: ‎12-02-2012
My Device: BlackBerry 8300
My Carrier: Personal
Accepted Solution

How to close this blocking modal dialog and open another after a few minutes

This is my method for displaying a modal dialog:

 

public static Dialog handleInactivityDialog(String msg, int[] values) {
     Dialog dialogo = new Dialog(msg, new String[] {"Yes", "No"}, values, 2, null);
     int i = dialogo.doModal();
     if (i == 1){
         try{
               //do something
               Utils.popScreenForLogout();
          }catch(Exception e){
               Utils.forceLogout();
          }
      }
      return dialogo;

}

 

After 3 minutes, that dialog must be closed and a new one should be opened. The new dialog should be closed after 1 minute.

 

I have no idea on how to do this since DIalog.doModal() is a blocking operation.

 

Thanks in advance!

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to close this blocking modal dialog and open another after a few minutes

you can start a timertask before you call doModal, for example.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
Contributor
Posts: 23
Registered: ‎12-02-2012
My Device: BlackBerry 8300
My Carrier: Personal

Re: How to close this blocking modal dialog and open another after a few minutes

Thanks Simon, I have read this answer:

 

http://stackoverflow.com/a/4348675/1293724

 

but I don't know how to adapt my code to that suggestion.

 

 

Contributor
Posts: 23
Registered: ‎12-02-2012
My Device: BlackBerry 8300
My Carrier: Personal

Re: How to close this blocking modal dialog and open another after a few minutes

public static void handleInactivityDialog(String msg, int[] values) {
         final Dialog dialogo = new Dialog(msg, new String[] {"Sí", "No"}, values, 2, null);
         Timer timer = new Timer();
         timer.schedule(new TimerTask(){

         public void run()
         {    
               synchronized (UiApplication.getEventLock()) {
                      int i = dialogo.doModal();
                      if (i == 1){
                            try{
                                   //do something
                                   Utils.popScreenForLogout();
                            }catch(Exception e){
                            Utils.forceLogout();
                            }
                      }
               }
          }

           }, 60*1000);

}

 

In case this is fine, where should I add the dialog.close() ?

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to close this blocking modal dialog and open another after a few minutes

the timertask would have the purpose the close the dialog, not to display it.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 23
Registered: ‎12-02-2012
My Device: BlackBerry 8300
My Carrier: Personal

Re: How to close this blocking modal dialog and open another after a few minutes

Ok, thanks Simon. This way works:

 

public static void handleInactivityDialog(String msg, int[] values) {
       final Dialog dialogo = new Dialog(msg, new String[] {"Sí", "No"}, values, 2, null);
       Timer timer = new Timer();
       timer.schedule(new TimerTask(){

                public void run()
                {
                   synchronized (UiApplication.getEventLock()) {
                               dialogo.close();
                   }

               }

      }, 60*1000);
     int i = dialogo.doModal();
     if (i == 1){
        try{
             CommManager.doLogout();
             Utils.popScreenForLogout();
         }catch(Exception e){
            Utils.forceLogout();
         }
     }  

}