Hello,
Does TimerTask work even if my exit my application and come to home screen or explore other apps? I have read the forum and find out the thread kind of easy mechanism is to use TimerTask in BB. I want to have thread running always even my app is not launched(after first time), so that when an particular interval arrives, i can show my dialog from application. I tried the below: (i am having this code, not in MainScreenClass instead first push screen class)
try {
timer = new Timer();
// start after 1 second, repeat every 5 second
// timer.schedule(new ClickTask(), 0, 5000); // seconds*1000
timer.scheduleAtFixedRate(new ClickTask(), 0, 5000);
} catch (Exception e) {
// do nothing
}
private class ClickTask extends TimerTask {
public void run() {
System.out.println("Test Printing..");
// Screen screen = new Dialog(Dialog.D_OK,
// "Look out!!!", Dialog.OK,
// Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION),
// Manager.VERTICAL_SCROLL);
}
}
But it does running the timer only when my application is launched. If i quit from my application and come to device home screen, seems to be log is not printing(i.e. timer is not running). Is my code right? Is this the way to run timer in the background as thread? Note: I'm testing on 9530 Simulator for this.
Thanks for your helps.