@Override protected void onStop() { super.onStop(); // Save the activity state in a Bundle Bundle state = new Bundle(); state.putString("name", mName); state.putInt("count", mCount); onSaveInstanceState(state); }
@Override protected void onStop() { super.onStop(); // Release resources that are no longer needed mMediaPlayer.release(); }
@Override protected void onStop() { super.onStop(); // Stop any running animations mAnimationDrawable.stop(); }In this example, the onStop() method is overridden to stop any running animations. This can help conserve system resources when the activity is no longer visible to the user. Package library: This code example is part of the android.app package library.