I require that from one activity (e.g Apple) a timer is automatically started to run for 20 secs and once the timer ends, its suppose to end to another activity (e.g. Orange).
But there is a button in Apple that allows me to click to another Apple activity (essentially a repeat), and the timer resets again in the new Apple.
The code for the timer as follows
new CountDownTimer(20000, 1000) {
public void onTick(long millisUntilFinished) {
public void onFinish() {
Intent i = new Intent(Apple.this, Orange.class);
Log.i(LG, "From Apple to Orange");
startActivity(i);
}
}.start();
If the Apple is activated once and exit to Orange, there's no problem.
But if one Apple(1) activity is activated followed by another Apple(2) activity, it seems that the timer for the Apple(1) does not stop. For example, if the I exit Apple(1) to Apple(2) when Apple(1) at 10 secs, for Apple(2), it only counts to 10 secs (not the full 20 secs) before exiting to Orange.
Where did I go wrong?