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

BlackBerry® World™ Development

Reply
Contributor
Posts: 13
Registered: ‎04-11-2011
My Device: 8320
My Carrier: software developer

popup window wait for an event to complete

hai i want my popup wondow(just "please wait") to show in the screen when some background process to complete

please help me

my code is like

 

i am calling the background event in this menu

 

 

 protected void makeMenu(Menu menu, int instance) {

 

            super.makeMenu(menu, Menu.INSTANCE_DEFAULT);
           
            menu.add(new MenuItem("Open", 20 , 10) {
            public void run() {
               
                 ScreenManager.showPleaseWaitPopup();
                 UiApplication.getUiApplication().invokeLater(new Runnable() {
                 public void run() {
                     try{
                        
                        Mpms.dataManager.getTaskDetails("",forReportList );//This is the back ground process  
                        UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen()) ;
                        Mpms.screenManager.display(Const.CONST_REPORT_LIST,null);//displaying the next screen 
                     }
                      catch(Exception ex){
                       UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
                       Dialog.inform(ex.getMessage());
                    }
                                                   });//add
The background process is downloading a image from the internet using a thread
This is the popup screen
 public static void showPleaseWaitPopup() {
        DialogFieldManager manager = new DialogFieldManager();
        CustomHorizontalFieldManager vertMng = new CustomHorizontalFieldManager();
        manager.addCustomField(vertMng);
        LabelField lblPlswait = new LabelField("  Please Wait...");
        lblPlswait.setFont(DisplayConstants.fntScreenTitle);
        vertMng.add(lblPlswait);
        Screen popup = new PopupScreen(manager);
        mainApp.pushScreen(popup);
}
the problem is the popup window is not showing and the image download is going on in itz thread
i want to show the popup until the completion of the download 
please somebody help i know the question is lengthy but i hav no other ways 
i am struck with this

 

 

Developer
Posts: 216
Registered: ‎02-18-2010
My Device: 9350,8520
My Carrier: no

Re: popup window wait for an event to complete

New Developer
Posts: 9
Registered: ‎11-24-2011
My Device: BB 9000
My Carrier: Dialog

Re: popup window wait for an event to complete

Not sure i'm too late to reply. i'm recently joined the forum

 

Try this code

 

DialogFieldManager manager = new DialogFieldManager();
manager.addCustomField(new LabelField("Please Wait..."));

final Screen popup = new PopupScreen(manager);
UiApplication.getUiApplication().invokeLater(new Runnable() {            
public void run() {                
 UiApplication.getUiApplication().pushModalScreen(popup); // pops up 'please wait' pop up window
}
});
Thread t=new Thread(new Runnable()
{
 public void run()
 {
  //your process
 }
});
UiApplication.getUiApplication().invokeLater(t);
while(t.isAlive()){
}
UiApplication.getUiApplication().invokeLater(new Runnable() {            
 public void run() {                
  UiApplication.getUiApplication().popScreen(popup); //hide wait popup screen
 }        
});