9-May-14 (Created: 9-May-14) | More in 'Android Basic UI'

Saving persistent data: onPause()

This call back indicates that the activity is about to go into background. You should stop any counters or animations that were running when the activity is fully visible. The activity may go to onResume or proceed to onStop. Going to onResume will bring the activity to the foreground. Going to onStop will take the activity into a background state.

As per the SDK it is also the last method that is guaranteed to be called before the activity and the process is completely reclaimed. So it is the last opportunity that a developer has to save any non-instance and persistent data to a file.

Android SDK also waits for this method to return before making the foreground activity full active. So you want to be brief in this method. Also notice that this method has no bundle that is passed. This is an indication that this method is for storing persistent data and also in an external storage medium such as a file or a network.

You can also use this method to stop any counters or animations or any status displays of a background task. You can resume them in onResume