jax jax - 19 days ago 10
Android Question

onStop() not getting called when I press the back button

Is this normal.

The docs say

"The onStart() and onStop() methods can be called multiple times, as the activity alternates between being visible and hidden to the user"

When I press the back button an it will go back to the previous activity which totally covers the old one.

What is going on here?

Answer

You want onPause(), not onStop(). onStop is called just before the activity is destoryed, when the system is low on memory. onPause is called whenever the user navigates away from your activity. See diagram at http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle.