Code example for ActionBarActivity

Methods: onPause

    // onPause is always called when the activity is undisplayed 
    // stop the counter thread here 
    protected void onPause() { 
        hiitRunner.pauseRunner();    // tell it to pause
        hiitRunner.interrupt();        // cancel the current timeout, if any
        // if there isn't a timeout, the exception will be raised without harm inside hangThread() 
        // just after we stop executing, release the screen lock 
        if (scrUnLock.isHeld()) scrUnLock.release();
    @Override protected void onDestroy() { 
        // if we're here, that means we've already paused the Runner thread 
        // thus, we set the flag for it to die and then pull it out of wait() so it returns 
        hiitRunner.resumeRunner();    // should not be necessary, but make sure it does not hang again