Is it possible to cancel a countdown timer in the onResume()
method ?
For example: when the back button is pressed the onResume()
method is called. I want to cancel the timer when it is in the login activity, in case of any other activity I want the timer to continue running.
I have thought about writing an if()
condition in the onResume()
activity and cancelling the timer but the timer does not stop.
My approach could be wrong, so please guide me.
void onResume(){
super.onResume();
if(currentActivity.equals("LoginActivity")){
timer.cancel;
}
}