According to Android documentation, finish() does exactly what the "back" button does. So basically onStop() is called when I call finish().
I tried to override onStateSaveInstance() to save the current state, but it is never called. However, if I go to the previous activity by creating a new Intent and using startActivity(), the method onStateSaveInstance() is called. Is there a reason for that?
Not necessarily.
onStop()is called when your activity is no longer visible.finish()only triggers a call toonStop()if the activity is visible when you callfinish().Correct. You are destroying the activity. There is no instance state to be saved.
Not necessarily. It will depend on
Intentflags,android:launchModein the manifest, etc.onSaveInstanceState()will not be called when your activity is being destroyed. There is no instance state to be saved, as the instance is going away.