@Override protected void onStop() { super.onStop(); // release any resources used by the activity mediaPlayer.stop(); }
@Override protected void onStop() { super.onStop(); // save the current state of the activity SharedPreferences.Editor editor = getSharedPreferences("MyPrefs", MODE_PRIVATE).edit(); editor.putString("username", username); editor.apply(); }This example demonstrates how the onStop() method can be used to save the current state of the activity. In this case, the username is saved to shared preferences when the activity is no longer visible. Package/Library: The package/library for BaseActivity would depend on the application structure and implementation. It could be a custom package/library created specifically for the application or it could be a part of the Android framework package/library.