Reputation: 31
I have a countdown timer method in main activity in which on finish method starts another activity. My problem is that while running the first activity and if I closed the app before the timer finishes. The app open the next activity by opening application. It works perfect if i waited till the timer finishes. I didn't minimize the app but I closed it, but it starts when the timer stops.
public void onFinish()
{
Intent resultPage = new Intent(context,ResultPage.class);
Bundle b = new Bundle();
b.putInt("score",score);
resultPage.putExtras(b);
startActivity(resultPage);
finish();
}
Upvotes: 1
Views: 190
Reputation: 373
Try this,
@Override
public void onDestroy() {
stopTimer();
super.onDestroy();
}
private void stopTimer() {
timer.cancel();
timer.purge();
timer = null;
}
}
Upvotes: 0