views:

36

answers:

1

Hi Friends,

I am using Blackberry eclipse environment , for blackberry application i am using start up screen with process bar , i am filing progress bar using timer, after process bar 100% completed then need to navigate the screen to another screen, i am checking like this

timer.cancel();

if(i>=99)

UiApplication.getUiApplication().pushScreen(new TipCalculatorScreen());

here i is time, increased form 0 to 100

but this code is not working how to navigate the screen form one page to another page after process bar is completed, please give me small example.

for process bar i am using code like this :

private GaugeField percentGauge;

percentGauge = new GaugeField(null, 0, 100,50, GaugeField.PERCENT);

             timer=new Timer();
               timer.scheduleAtFixedRate(new TimerTask(){
                   int i=0;

                   public void run() {
                       percentGauge.setValue(i);
                          i++;
                             if(i>=99)
                             {
                                 timer.cancel();

                                   //for page navigating i am given like this here screen is not navigating getting error
                           UiApplication.getUiApplication().pushScreen(new nextscreen());   

                             }       

                       }
               }, 100,100);
A: 

You need to make changes to the UI on the UI thread. The TimerTask is executing on its own thread. Instead of

UiApplication.getUiApplication().pushScreen(new nextscreen());

you should use

UiApplication.getUiApplication().invokeLater(new Runnable() {
    public void run() {
        UiApplication.getUiApplication()..pushScreen(new nextscreen());
    }
});

The update to your gauge control probably needs the same treatment.

Jason Prado
Thankq very much.......its working fine
upendra
Good to hear :) Here on stackoverflow you can mark an answer as Accepted so others know it's a good answer (and I get credit for it).Good luck!
Jason Prado