Skip to content Skip to sidebar Skip to footer

Onpause() Or Onstop()

This isn't working the way I expected. However, the way I expect it to work is probably wrong. I have an application that implements a Countdown timer. When the back button on the

Solution 1:

Try:

movetasktoback(true);//in the onbackpressed

Then use the:

countdowntimer.cancel();// in onpause

After that you can call finish() in onpause().

Solution 2:

why dont you call countdowntimer.cancel() when back key is pressed you can override back click like

@Override
     public boolean onKeyDown(int keyCode, KeyEvent event)  {
         if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
             countdowntimer.cancel();
         }

         return super.onKeyDown(keyCode, event);
     }

Post a Comment for "Onpause() Or Onstop()"