jax jax - 1 year ago 66
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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download