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

Reply
New Developer
ivanro
Posts: 4
Registered: ‎01-05-2009
My Device: Not Specified
Accepted Solution

How to freeze the application waiting for a popscreen answer

Well I was developed a custom pop screen and I want to know how to stop my application until the pop screen return a answer something like Dialog.Ask() someone have any idea How can I start to do that, Thank you for your time.

Ivan
Developer
Developer
rab
Posts: 283
Registered: ‎07-22-2008
My Device: Not Specified

Re: How to freeze the application waiting for a popscreen answer

Something that comes to my mind goes like this:

 

myPopup = new customPopUP(.....) ----> this is when you create your popup.

 

in the popup screen you add a flag that satisfy your condition, called for example : done.

 

then in the waiting App you do something like this:

 

while (!myPopup.done) 
 {
      synchronized (this) 
       {   
             try 
              {
                    //optional:increment a time out counter if you want to add a time out
                    wait(50);
               }
                catch (Exception e) {}
        }


 //optional

// test if you timed out to continue or abort
   }

.

.

.

continue your process

.

.

 

Basically you add a while statement, with a condition, which includes a wait() or a sleep() or just an empty one.

You can add as shown above a time out to it so that you cannot wait forever.( Optional depending on your requirement)

 

I hope this can help.

 

Rab

New Developer
ivanro
Posts: 4
Registered: ‎01-05-2009
My Device: Not Specified

Re: How to freeze the application waiting for a popscreen answer

Actually a test your solution but is blocking all my app the code that user is de the next

ListPopup dialogList = new ListPopup("List",listField);
UiApplication.getUiApplication().pushScreen(dialogList);
while (!dialogList.done)
{
synchronized (this)
{
try
{
wait(500);
}
catch (Exception e) {}
}
}

 

 

New Developer
ivanro
Posts: 4
Registered: ‎01-05-2009
My Device: Not Specified

Re: How to freeze the application waiting for a popscreen answer

After a while to read the documentation I find the solution instead of to user pushScreen() we have to user pushModalScreen().This method does not return until you invoke popScreen(Screen). You must invoke this method on the event thread :smileytongue: Thank you for your time.
Developer
sheepk
Posts: 30
Registered: ‎06-01-2009
My Device: 9000 Bold

Re: How to freeze the application waiting for a popscreen answer

Hi,

 

I'm trying to do something very similar.

 

Could anybody tell me how to catch the answer coming from the custom popup?

 

 

Dialog.ask returns int type, but we can't tell pushModalScreen to return an int nor a boolean... Could you please tell me how to do this?

 

 

Thanks. 

New Developer
Posts: 14
Registered: ‎07-18-2008
My Device: Not Specified

Re: How to freeze the application waiting for a popscreen answer

Construct a new instance of net.rim.device.api.ui.component.Dialog with the approriate options and then call its doModal() method - this will block (similar to Dialog.ask() ) and then return an int corresponding to the user's choice in the dialog.

 

James

CTO | DevelopIQ
www.developiq.com
Developer
sheepk
Posts: 30
Registered: ‎06-01-2009
My Device: 9000 Bold

Re: How to freeze the application waiting for a popscreen answer

[ Edited ]

Thank you for your answer.

 

I found an other solution with my custom popup :

 

 

I made a method in my popup class called "getAnswer", returning the answer choosen by the user.

 

Then, I used that code to disp my popup and wait for the answer : 

 

 

	private boolean dispPopupConfirmBlk()
{


UiApplication.getUiApplication().invokeAndWait( new Runnable(){
public void run() {
String texte = "Question ?";
dialogWinYESNO = new DialogYTYESNO(texte, true);
UiApplication.getUiApplication().pushModalScreen(dialogWinYESNO);

_questionbis = dialogWinYESNO.getAnswer();

}
}
);
return _questionbis;

}

 

And it works great  :smileywink:


 

Message Edited by sheepk on 09-29-2009 12:30 PM