You just put this in your onPause()
method of your activity:
@Override
public void onPause() {
handler.removeCallbacksAndMessages(null);
super.onPause();
}
So when your app goes to the background, it will remove the callbacks on the Handler. This also works for the back button AND the home button.