I think what you want to do is call onPause , however you do not want to do too much. Here's what the docs say :
protected void onPause () Added to API level 1
Called as part of the life cycle of an activity when an activity occurs in the background, but has not yet been killed. Analogs onResume ().
When action B starts before activity A, this callback will be called on A. B will not be created until A onPause () is returned, so be sure to do nothing long here.
This callback is mainly used to maintain any constant state of activity being edited, to present the user with "in-place editing" and to make sure that nothing is lost if resources are insufficient to start a new activity without first killing it. It is also a good place to do something like stopping animations and other things that consume a significant amount of CPU, to make the switch as fast as possible, or to close resources that have exclusive access, such as a camera.
source share