HI , i have made simple application in blackberry with 3 view controllers with some functionality .. what i want to do now is add a time at the top of the main screen . and it should b running till i quit from application .. i will move to other view controllers also but that timer would b running & keep displaying the time,i hav implememented some timer code,& its working fine in the main screen,bt as soon as i move to another screen,it get reset to 00:00,& start 2 increase again,i want to avoid this reset,the time should keep on incrementing through out the app.. how i will have this functionality ?? Actually i hav TestScreen page frm where the application starts,then it calls the TopManager page where the timer code is defined,then when we click a particular answer,it goes to Answer Screen,where we again call TopManager t=new TopManager,so for this everytime it shifts frm testscreen to anssweer screen,the timer starts frm fresh,i tried to use static,bt dont hav much success,can anyone helpe me? here is my code
Timer t=new Timer();
TimerTask tt=new TimerTask() {
long startTime = System.currentTimeMillis();
public void run() {
synchronized (Application.getEventLock()) {
currentTime = System.currentTimeMillis();
diff = currentTime - startTime;
min = ( diff/ 60000);
sec = ( diff%60000) / 1000;
minStr = new Long(min).toString();
System.out.println("abccccccc"+minStr);
secStr = new Long(sec).toString();
System.out.println("xyzzzzzzzzz"+secStr);
if (min <30){
minStr = "0" + minStr;
}
if (sec <30){
secStr = "0" + secStr;
}
TimerCount.setText(String.valueOf(minStr + ":" + secStr));
}
}
};
t.scheduleAtFixedRate(tt,1000,1000);
TimerCount = new LabelField("00" + ":" + "00"){
protected void paint(Graphics g) {
g.setColor(Color.WHITE);
super.paint(g);
}
};
TimerCount.setFont(myFont(16));
add(TimerCount);